pyagentos-sdk
Official Python SDK for AgentOS, the operating system for agent-run companies.
- Run hosted agents from your code:
invoke,invoke_stream, conversations, and replies to agents that ask a question. - Report agents that run in your own code: runs, events, spans and token usage, with the same history, alerts and reports as hosted agents.
Events are queued and sent from a background thread, with retries. If AgentOS is slow or down, your agent keeps running.
Install
pip install pyagentos-sdk
The package is pyagentos-sdk; import it as agentos. Python 3.10+.
Quick start
Create a key on your agent's Keys tab and set it in the environment:
export AGENTOS_API_KEY=aos_agent_...
export AGENTOS_AGENT_ID=...
Run a hosted agent
from agentos import AgentOS
aos = AgentOS()
result = aos.invoke({"prompt": "Summarise yesterday's tickets"})
if result.status == "completed":
print(result.output)
# A run can also pause: "awaiting_approval" or "awaiting_input" (answer it with aos.reply()).
for event in aos.invoke_stream({"prompt": "Draft a reply"}):
if event["type"] == "chunk":
print(event["text"], end="", flush=True)
Report your own agent
with aos.start_run(input={"ticket": 42}) as run:
step = run.start_span("classify", kind="step")
run.emit_tool_call("search", {"q": "refund policy"})
step.end()
# Completed when the block ends; failed, with the traceback, if it raises.
Or end the run yourself with complete() / fail() / cancel(). In serverless functions, call aos.flush() before returning.
LangChain
pip install "pyagentos-sdk[langchain]"
from agentos.langchain import AgentOSCallbackHandler
with aos.start_run() as run:
chain.invoke(inputs, config={"callbacks": [AgentOSCallbackHandler(run)]})
Chains, models, tools and retrievers appear as a span tree with model names and token counts.
Documentation
Full reference, options and error types: agentos-ai.dev/docs/sdk-python. What changed: CHANGELOG.md.
License
MIT
Metadata
Release files for pyagentos-sdk 0.3.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 | |
|---|---|---|---|
| pyagentos_sdk-0.3.0.tar.gz | 25.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyagentos_sdk-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.6 kB
Release files / pyagentos_sdk-0.3.0.tar.gz
| Download URL | pyagentos_sdk-0.3.0.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adbe2974fe3d1b2da97d1d891f5dcc6b96cc4f5a6b44fefc8a0f8e6e98b54be3
|
|
BLAKE2b-256 checksum How to use checksums |
b141b75d90a06f7cfdc00492054fa0f60fefa6dfba3dbfefd0b74a4b683780ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / pyagentos_sdk-0.3.0-py3-none-any.whl
| Download URL | pyagentos_sdk-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e405871478f35cf8eb71e812613e437d4e47c14042815dda6a414ef89fd18c4
|
|
BLAKE2b-256 checksum How to use checksums |
c163926dbbd47d37fcd326615a29fc3b9495679db9ed491fd52814d6b38739b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|