cf-agents
Cloudflare Agents for Python Workers
Features
- Typed,
async-first Python 3.12+ - FFI Handling under the hood. Just write Python, we handle talking to the runtime.
- Behavioural and API parity with the TypeScript Agents SDK.
Installing
It's recommended you use uv - you'll need to use pywrangler to deploy to Cloudflare.
$ uvx --from workers-py pywrangler init
$ uv add cf-agents
Quickstart
The Agent class gives you the core tools to build stateful, durable agents.
from agents import Agent, callable, route_agent_request
from workers import WorkerEntrypoint, Response
from utils import google_search
class LunchAgent(Agent):
initial_state = {"votes": {}}
@callable
async def search_restaurants(self) -> list[str]:
restaurants: list[str] = await google_search(
"Korean BBQ places near County Hall"
)
return restaurants
@callable
async def vote(self, person: str, restaurant: str):
votes = self.state["votes"]
votes[person] = restaurant
self.set_state(self.state)
class Default(WorkerEntrypoint):
async def fetch(self, request) -> Response:
response = await route_agent_request(request, self.env)
return response or Response("Not Found", status=404)
It can get tedious implementing similar patterns for chat agents over and over again. See AIChatAgent.
Links
Metadata
Release files for cf-agents 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cf_agents-0.1.1.tar.gz | 206.9 kB | Without provenance | Details for cf_agents-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cf_agents-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cf_agents-0.1.1-py3-none-any.whl |
Total release size: 466.7 kB
Release files / cf_agents-0.1.1.tar.gz
| Download URL | cf_agents-0.1.1.tar.gz |
|---|---|
| Size | 206.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f0aca824ae83e816843b5bf4ef9bdcab676246566ce8ce00439634a98b33342
|
|
BLAKE2b-256 checksum How to use checksums |
a007faa2905ea89cb83a934e414e2d5b8da78ade10918363761ea9b334127d23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cf_agents-0.1.1-py3-none-any.whl
| Download URL | cf_agents-0.1.1-py3-none-any.whl |
|---|---|
| Size | 259.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37459b45d986e1f3ab085dcd46d8b6c30d0d90d4f7410e4bac97d81cbe27ec37
|
|
BLAKE2b-256 checksum How to use checksums |
8fd8fc68ad4384865c1c66f98594d72bf31460d4ff73be60da4531c181fe05b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cf-agents 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.