GET /health and POST /invoke) and wrap every platform call an agent makes. You write one function per capability; the SDK calls it with the invocation and turns what it returns into the right answer.
Everything the SDKs do is one of the documented HTTP calls, so an agent in any other language loses nothing by using plain HTTP. Check either way with the conformance kit.
A first handler
Putting the SDK in your bundle
The SDKs aren’t published on PyPI or npm yet. They ship with AgentOS as a Python wheel (agentos_sdk-0.1.0-py3-none-any.whl) and an npm tarball (agentos-sdk-0.1.0.tgz). Put the file in a vendor/ folder of your bundle and install it from there in your Dockerfile:
- Python
- TypeScript
Dockerfile
RUN pip install "$(ls vendor/*.whl)[langgraph]".For local development and tests, pip install vendor/agentos_sdk-0.1.0-py3-none-any.whl into your virtual environment.vendor/ in it and deploy as usual.
The invocation
A handler gets the invocation,inv, with input, capability, run_id / runId, session_id / sessionId, user, kind, id, seq, attempt, config, secrets, resume and eval, plus these helpers:
Python’s platform calls are synchronous, each with an async twin (
aask, astart, aevent, state.run.aget …), and async handlers work too.
inv.eval is None / null on a normal run. On an experiment run it holds the holds recorded for the dataset item. Keeping side effects (payments, emails) out of eval runs is your code’s job: check it.
Answers and errors
A
Fail code is lowercase letters, digits and _, starting with a letter, at most 63 characters, with a non-empty message (the platform would record anything else as agent_failed, so Python’s Fail refuses it with a ValueError).
Platform refusals raise AgentOSError subclasses: InvalidRequest (and GuardrailBlocked, with guardrail, at, hit), Unauthorized, Forbidden, NotFound, Conflict (and VersionConflict, with current_version), TooLarge, and InvocationEnded when your code uses the invocation after it answered. agentos.guardrail_block(error) / guardrailBlocked(error) find a guardrail block inside another client’s error (see Guardrails).
Serving
The run token in your own HTTP clients
The SDK sends the run token only to the platform and the model gateway, and only while the invocation runs; afterwards it raisesInvocationEnded instead of sending it. Your own clients should follow the same rule:
- Python:
httpx.Client(event_hooks=agentos.httpx_event_hooks())(async_httpx_event_hooks()forAsyncClient) adds the token to requests for the platform’s hosts and takes it off any request to another host, redirect hops included: once a request has left the platform, its later hops never get the token. A thread pool doesn’t inherit the invocation: submitagentos.bind(fn). - TypeScript:
inv.fetch(url, init)orplatformFetch(url, init)follow redirects themselves with the same rule. The invocation follows awaits and timers, not worker threads.

