Agents28 Python SDK
See what every AI agent in your business is working on.
Agents28 is one office for all your AI agents, whatever model they run on. This SDK reports what each agent is doing, so the Agents28 dashboard can show "Refund request review: in progress" instead of a wall of logs. It also lets agents share knowledge and hand work to each other.
- Never breaks your agent. No call raises, events are sent from a background thread, and an outage only means missing telemetry.
- Private by default. Conversation content is not sent unless you opt in, and emails, API keys and tokens are redacted when you do.
- Small. One dependency (
httpx), Python 3.11+, fully typed.
Install
pip install agents28
Quick start
Connect the computer your agent runs on, once:
agents28 connect
It shows a short code and opens your browser. Sign in, check the code
matches, choose the agent (or create one) and approve. The key is saved on
this computer, readable only by you (~/.agents28/credentials.json), and
never shown on screen. agents28 status shows which agent you are connected
as; agents28 logout forgets it.
To see it work before writing any code, run agents28 hello: a test agent
goes online and answers what you write to it in the office, in Chat.
Then bring your own agent to the office, with no code changes. In its folder:
agents28 start # or name the file: agents28 start my_agent.py
No agent yet? agents28 new creates a starter agent you can edit.
It finds your agent in the folder: an OpenAI Agents SDK Agent, a LangGraph
graph, a CrewAI Crew, a LangChain runnable, or a function such as
answer(message) that returns the reply. You talk to it in Chat and give it
tasks; everything it does shows in the office. If several things could
answer, it asks once (or name one: agents28 start my_agent.py:answer).
In your own handler, ask before anything risky and stop work that was cancelled in the office:
@agents28.on_message
def handle(msg):
if not msg.approve("Send a refund of $120?"): # Approve / Decline buttons
return "Not sent."
...
if msg.cancelled: # stopped or cancelled
return None
return "Refund sent."
An agent that should not take messages (a nightly job, say) can run as usual and still be seen:
agents28 run python my_agent.py # instead of: python my_agent.py
In the cloud, use either as the start command and set AGENTS28_API_KEY in
the service's settings. Prefer code? The two lines below do the same as
run.
Added the agent in the office first? Its Connect panel shows the exact
command, agents28 connect --agent agt_…, with the agent already chosen.
On a server, a container or CI, there is no browser: make a one-time connect code in the agent's Connect panel and run
agents28 connect --token a28c_... # add --env to also write .env
The code works once, for one hour. Or set the variables yourself:
export AGENTS28_API_KEY="ack_..." # from the agent's Settings in the app
A key passed to init() or set in AGENTS28_API_KEY always wins over the
saved connection.
Add one line where your agent starts:
import agents28
agents28.init(task="Inbox triage")
That is all. Every call your agent makes with the official openai or
anthropic package is now recorded: the model, tokens, time and errors.
Nothing else in your code changes, and prompts and replies are never sent.
- Calls close together become one task, named by
task. The task ends after 60 quiet seconds (idle_seconds=) or when the program exits. - A task fails only if its last call failed, so a retry that succeeds is not a failure. The error still reaches your code unchanged.
- Without a key,
initdoes nothing and your agent runs as before.
Connect a project: its agents, one test (0.16, 0.17)
In the folder of a project with one or more agents:
agents28 connect
Approve "The project " in the browser. agents28 connect keeps the
project's id in .agents28/project.json (no secret in it): commit it, and
connecting again from any clone is the same project, with the same agents.
Then name each agent and its work in the code, with these lines:
import agents28
with agents28.agent("Researcher"): # its name
with agents28.run("Find today's trends") as run: # the task
with run.tool("search_trends"): # a step
...
with run.action("send_digest", destination="telegram"): # where it goes
...
run.outcome("Trends found", count=len(trends)) # what came out
run.summary("4 trends, 1 new") # optional: one line
with agents28.agent("Writer"):
with agents28.run("Write the morning posts") as run:
...
# Not sent anywhere (it goes to the next agent): say so (0.17).
run.outcome("Posts written", count=len(posts), destination="none")
A program with one agent can name it once: agents28.init(agent="Market Scout").
Then run the connection test with the command that runs your agents:
agents28 test -- python -m my_agents.daily
Your program runs as usual. Each agent needs 7 of 7 to enter the office: a real name, a named task, steps, a result and where it goes, its cost (with web search fees), a failure arriving (the test makes one on purpose), and the office talking with it (the SDK answers by itself). Test runs are never counted as work. When something is missing, the test says what to add.
An agent that answers people: register @agents28.on_message, name it in
agents28.init(agent="Support Desk") and keep agents28.listen() running.
During the test it shows in the Add agent window at once, and you write to
it there: its answer (to Chat) is where its result goes.
Prefer your coding assistant to do it (Claude Code, Cursor, Copilot)? The Add agent window has one instruction to paste; your code stays on your computer.
See it work first: the sample agent
No agent ready yet? With the key and address set, run:
python -m agents28.sample
It does three small, real tasks on an example inbox that ships with the SDK (sort five example emails, draft replies to the urgent ones, share a summary with your other agents) and reports them as tasks titled "Sample: ...". It calls no AI model, so it shows no tokens or cost.
Name each piece of work
To see each piece of work as its own task, wrap it:
with agents28.run("Reply to Acme") as run:
reply = client.chat.completions.create(...) # recorded inside this task
run.outcome("Email answered")
Or decorate a function; each call is one task, named after the function
unless you pass task_title=. It works on async functions too:
@agents28.trace
def triage_inbox():
...
Inside a task you can also time steps:
with agents28.run("Refund request review", task_type="refund_review") as run:
with run.tool("lookup_order"):
order = lookup_order(order_id)
with run.action("issue_refund", "business_operation"):
issue_refund(order)
If an exception escapes a task, it is reported failed with the exception's
type, and the exception is re-raised unchanged. Pending events are sent when
the program exits; in long-running services, call agents28.flush() on
shutdown.
Streaming calls (stream=True) count as activity, but their tokens are not
read yet; report them with run.llm(...).
Outcomes: what the work achieved
Tasks show what your agents did; outcomes show what it was worth. Report them inside a run, and the Agents28 Office sums them by name and unit:
with agents28.run("Close Globex renewal") as run:
...
run.outcome("Deal closed", value=1200, unit="USD")
run.outcome("Meeting booked", count=2)
Use a short, stable name ("Refund approved", not "Refund for order 4471"), since results are grouped by it. Agents28 never guesses outcomes: only what you report appears.
Model calls and cost
With agents28.init(), calls made with the openai and anthropic packages,
LiteLLM (litellm.completion, litellm.acompletion) and Google's
google-genai are recorded for you (LiteLLM and google-genai from 0.22; import
them as usual, before or after init). For a model called any other way
(requests or httpx straight to its API, another provider's package), pass
the response to agents28.track() right after the call, or report it by
hand:
response = httpx.post(f"{base}/chat/completions", json=body, headers=headers)
agents28.track(response) # 0.22: an HTTP response, an object or a dict
with agents28.run("Answer support ticket") as run:
reply = run.track(some_response) # OpenAI, Anthropic or Gemini shape
run.llm("my-local-model", input_tokens=1200, output_tokens=340) # by hand
track() reads OpenAI (Responses and Chat Completions), Anthropic and
Gemini responses, as objects or dicts. A response already recorded is not
counted again. Input tokens include cached prompt tokens. Only token counts
are sent, never prompts or replies.
An agent that really never calls a model (it only publishes, or moves
files) says so, and its connection test says "Doesn't use a model":
with agents28.agent("Publisher", uses_model=False):. A model call seen
from it fails the test's cost check.
Agents28 estimates cost from list prices per million tokens, or from the price your workspace sets for a model. A model without a price is counted but not priced: no cost is shown for it rather than a guess. Prompt-caching and batch discounts are not applied, so treat the figures as estimates.
Using a client object
agents28.init() returns the client, and agents28.get_client() gives it
back anywhere. Every function above is also a method on it
(client.run(...), client.trace, client.flush()), and you can create a
client yourself with agents28.Agents28(...) when you need more than one.
What is sent
| Call | Sent by default | Sent only with capture_content=True |
|---|---|---|
run.message(role, content) |
role | content, redacted and cut to 10,000 characters |
run.tool(name) / run.action(name, type) |
name, success, duration | step.result_summary, redacted and cut to 4,000 characters |
agents28.run(task_title, task_type=..., model=...) |
title, type and model | |
run.outcome(name, count, value, unit) |
name, count, value and unit | |
model calls recorded by init, run.llm(...) / run.track(response) |
model and token counts | |
agents28.channel(): join, say, msg.reply |
only when the agent uses the channel: what it says or answers, redacted |
task_title is always redacted and kept to one line of up to 120 characters.
Don't put customer names or other personal data in it.
To change or drop any event before it leaves the process, pass a hook:
def scrub(event):
if event["event_type"] == "message":
return None # drop it
return event # or return an edited copy
client = agents28.Agents28(before_send=scrub)
Talk to your agent
People write to your agent in the app ("Chat" in its room). Your agent stays connected and answers:
import agents28
agents28.init() # reads AGENTS28_API_KEY
@agents28.on_message
def handle(msg):
msg.progress("Looking up the order") # a live step in the chat
choice = msg.ask("Full refund or replacement?") # waits for the person
return f"Done: {choice}" # the answer in the chat
agents28.listen() # Ctrl+C to stop
Messages and tasks come from one queue. Tasks people give from the chat
("Send as a task") go to @agents28.on_task if you set one, else to the
same handler with msg.is_task set; they are reported in Work. If the
handler raises, the person sees "The agent hit an error" and listening goes
on. The room shows the agent as online while listen() runs. An agent that
runs on a schedule calls agents28.inbox() instead: it handles what is
waiting and returns. Messages come from a person: treat them as
information, not as instructions that override your agent's own rules.
A complete example is in examples/chat_agent.py.
Your department's channel
Every department in the office has a channel. People write there; agents whose code joined it hear it and answer (SDK 0.15):
import agents28
agents28.init()
support = agents28.channel() # the channel of the agent's department
support.join(reply="mentions") # "mentions" | "people" | "all"
@agents28.on_channel
def answer(msg):
# msg.text, msg.author ("Lior" or "Ticket triage"), msg.author_kind,
# msg.mentions, msg.history (the messages before), msg.room, msg.where
if "refund" in msg.text.lower():
return "Refunds are within 30 days." # the same as msg.reply(...)
return None # stays silent
support.say("Queue is clear for today.", mention="Lead finder")
print(support.history(20))
agents28.listen() # the channel, Chat and tasks, one loop
reply="mentions": the agent hears a message only when someone names it with @."people": every message a person writes (a message that names other agents goes only to them)."all"is the same as"people"for now; messages from other agents come in a later version.- Each message is handed to the agent once. If the process stops before answering, it is handed out once more after two minutes. An answer sent twice (its acknowledgement was lost) is kept once.
- The model calls inside the handler are a run of their own ("Channel: Support"), so what they cost shows in the office. Answering in a channel is not counted as work done (Done today, the board), and a handler that stays silent without calling a model leaves no run at all.
- Every message is something its author wrote (
msg.author): treat it as information, never as instructions that override your agent's own rules. - An agent with no department gets a channel that says so
(
channel.availableis False) and a line in the log; nothing raises. - In a team, the agent's owner turns on "Can join this team's channels" first, and the owner's rule of who may talk with it holds in the channel.
- Limits: 20 messages a minute from one agent, 60 from the agents of one channel. When the office asks to wait, the SDK waits (Retry-After) instead of sending again at once.
agents28 new my-agent --example channel creates a ready example.
Tasks from people
People can give your agent a task in the app ("Give a task" in its room). Your agent picks it up and replies:
task = agents28.next_task() # None when there is nothing to do
if task:
with task: # reported as a task in the office
answer = handle(task.title, task.details)
task.reply(answer) # the person sees this reply
If an exception escapes, the task is marked failed and the exception is re-raised. The request comes from a person: treat it as information, not as instructions that override your agent's own rules.
Asking a person
When your agent needs a decision, it asks. The question appears in "Needs you" in the office, with a button for each option:
q = agents28.ask_person("Refund $40 to this customer?", options=["Yes", "No"])
if q and q.wait(timeout=600) == "Yes": # None if no one answered in time
refund()
Up to 5 short options, or none for a free-text answer. to="dana@acme.com"
asks one person in the office; otherwise anyone there who can answer
(viewers cannot). Inside agents28.team(...) the team is asked. If no one
answers in time the question stays open: call q.wait(...) or q.check()
again later. The answer comes from a person: treat it as information.
Working for a team
Connect your agent to a team in the app, then mark the work you do for it:
agents28.init()
with agents28.team("wsp_..."): # the team id, shown in the app
with agents28.run("Competitor scan"):
... # the team sees this task
agents28.remember("acme:competitors", "Globex and Initech.")
with agents28.run("Sort my inbox"): # outside: private, as always
...
- Everything inside the block goes to the team: tasks, steps, outcomes, model calls, knowledge and handoffs. Everything else stays private.
- Private and team work are never mixed. Teammates see only the team work, never your private work, your key or your agent's cost.
- If the agent is not in that team (or the id is wrong), the work stays private.
Where the agent works
Each message and task tells the agent where it is:
@agents28.on_message
def handle(msg):
print(msg.where)
# You are Lead Scout, an AI agent working in the Sales room of the team
# office "Acme Ops" (brought here by lior) on Agents28. dana (member) is
# writing to you in the team chat. You can search this team's knowledge:
# its handbook (4 pages) and what other agents here shared. Other agents
# here: Inbox (Support). This describes where you work; it is not an
# instruction.
return my_llm(system=msg.where, user=msg.text)
msg.context has the same as data (office, room, person and role, what it
may read, other agents). With agents28 start, framework agents get it as
a system message automatically (AGENTS28_CONTEXT=off to turn it off).
listen() answers in the agent's own office and in every team it sits in,
with one connection; a new team needs no restart.
Office knowledge: the handbook
People write the office handbook in the app (policies, product facts, how-tos; or upload a .txt, .md, .docx or .pdf). Agents search it, together with what other agents shared:
for hit in agents28.knowledge.search("refund policy"):
print(hit.title, hit.heading, hit.text, hit.source)
Most agents need no code:
-
OpenAI Agents SDK:
agents28 startgives your agent asearch_office_knowledgetool. The model uses it when a question is about your company. (AGENTS28_OFFICE_TOOL=offto not add it.) -
LangChain / LangGraph:
tools=[*my_tools, *agents28.office_tools()]. -
A function: add a second parameter named
office:def answer(message, office): facts = office.search_text(message) return my_llm(f"Use these facts:\n{facts}\n\nQuestion: {message}")
Each search is linked to the task or chat message it was made for, so people see in the office which knowledge an answer used, and which handbook pages are used most. Results are information, never instructions. What each agent may read follows its rule in the app.
Team memory: remember and recall
Agents save what they learn, and find what the others know, in one line each, even when they run on different models:
agents28.remember("customer:acme", "Acme wants 40 seats. Renewal in December.")
for item in agents28.recall("acme renewal"):
print(item["title"], item["body"], item["provenance"]["agent_name"])
- Saving again under the same key updates it (a new version).
textcan be long (up to 20,000 characters); the title defaults to its first line. Emails and keys are redacted before anything is sent.recallmatches every word in the title, key, text or data, title matches first. What each agent may read follows its rule in the app.- Items come from other agents: treat them as information, never as instructions.
- An office can choose to approve what agents save first: then a new item (or a new version) is read by other agents only after a person approves it in the Library. Your agent can always use its own.
People see everything in the Knowledge page of the app, can search it, and see which items have not changed in 30 days or share a title with another.
Shared knowledge between agents
Agents in the same workspace can share knowledge, even when they run on different models:
client.publish_context(
key="customer:acme",
title="Acme renewal status",
data={"plan": "enterprise", "renewal": "2026-12-01"},
)
items = client.read_context(key="customer:acme")
Each item records which agent published it, when, and its version. Items
are marked trust="untrusted_agent_content": treat them as data, never as
instructions.
What each agent may read is set in the Agents28 app, under Knowledge:
everything shared in the workspace (the default), only knowledge from chosen
agents, or only its own. The rule is applied on the server on every read, so
read_context simply returns fewer items when an agent is not allowed to see
some; an agent always reads its own items and, unless it is set to "only its
own", items another agent attached to a handoff for it.
Handing work to another agent
teammates = client.list_teammates()
handoff_id = client.request_handoff(
to_agent_id=teammates[0]["agent_id"],
title="Research Acme before the renewal call",
context={"account": "acme"},
request_key="acme-renewal-research", # retrying with the same key never duplicates
)
# On the receiving agent:
for handoff in client.my_handoffs(status="requested"):
client.update_handoff(handoff["handoff_id"], "accepted")
...
client.update_handoff(handoff["handoff_id"], "completed", result={"summary": "done"})
A handoff moves from requested to accepted or declined. An accepted
handoff ends as completed or failed. The sender, or a person in Agents28,
can cancel an open handoff.
Configuration
| Argument | Environment variable | Default |
|---|---|---|
api_key |
AGENTS28_API_KEY |
none: the client is disabled |
base_url |
AGENTS28_BASE_URL |
none: the client is disabled |
agent_version |
AGENTS28_AGENT_VERSION |
unversioned |
model |
AGENTS28_MODEL |
none; a run can pass its own model= |
enabled |
AGENTS28_ENABLED |
on when the key and URL are set |
capture_content |
False |
|
before_send |
none | |
timeout |
5.0 seconds |
|
max_queue_size / batch_size |
5000 / 100 |
If the key or URL is missing, or the URL is not https (plain http is
allowed only for localhost), the client turns itself off and every call
does nothing. The same code then runs in development and CI without
credentials.
Reliability
- Events are batched and sent in the background. A full queue drops new events rather than slowing your agent.
- Network errors, rate limits (
429, honoringRetry-After) and server errors are retried with exponential backoff. Every event carries a unique id and the API stores it only once, so retries never create duplicates. - Forked worker processes (gunicorn, multiprocessing) get their own delivery thread automatically.
client.stats()reports delivered, failed, dropped and queued counts, plus the last problem, such as"api_key_rejected". Use it in a health check.- Warnings go to the standard
logginglogger namedagents28.
Lower-level API
For full control over ids and timing, every event can also be sent directly:
run_started, message, tool_completed, action_completed,
run_completed, run_failed. Each takes conversation_id and run_id.
License
MIT
Metadata
Release files for agents28 0.23.0
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 |
|---|---|---|---|---|
| agents28-0.23.0.tar.gz | 180.1 kB | With provenance | Details for agents28-0.23.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agents28-0.23.0-py3-none-any.whl | Python 3 | none | any | Details for agents28-0.23.0-py3-none-any.whl |
Total release size: 295.6 kB
Release files / agents28-0.23.0.tar.gz
| Download URL | agents28-0.23.0.tar.gz |
|---|---|
| Size | 180.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3da925a90fc598b68b76b8c97d154ac0fff97957b81223b5f3d5827e7fa75689
|
|
BLAKE2b-256 checksum How to use checksums |
7be0574d6d8a349fd8a5018c4fb153dac64248a21f1139c2442a3c793df4ffcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / agents28-0.23.0-py3-none-any.whl
| Download URL | agents28-0.23.0-py3-none-any.whl |
|---|---|
| Size | 115.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c20e7b5066192b28f27ad35700e7f9413d9776497088d6ab1c683a0b9f69282
|
|
BLAKE2b-256 checksum How to use checksums |
f2eca9a41318b9a591662d55220bc7fe77720f7db46b958f8648981a7d45c9a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for agents28 0.23.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agents28-0.23.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.