AFK is the Python SDK for building AI agents that are reliable by default. Define agents with typed contracts, wire in tools and policies, and ship to production with observability, evals, and safety limits built in.
Install
- pip
- poetry
- uv
NOTE: You need an LLM provider API key. Set OPENAI_API_KEY, or configure any provider supported by LiteLLM.
Your first agent
What just happened?
What just happened?
Agent(...)defines the agent — its name, model, and system prompt instructions. 2.Runner()creates the execution engine with safe defaults (headless mode, in-memory state). 3.run_sync()sends the user message to the LLM, waits for the response, and returns anAgentResult. 4.final_textholds the model’s response.statetells you how the run ended (completed,failed,degraded, orcancelled).
Add a tool in 30 seconds
What AFK gives you
Agents
Define agents with typed inputs, instructions, tools, and subagents.
Single-agent or multi-agent — you choose.
Runner
Execute agents synchronously, asynchronously, or with real-time streaming.
Pause, resume, cancel at any point.
Tools
Give agents capabilities through typed Python functions. Schema validation,
policy gates, and output sanitization built in.
Memory
Persist conversation state across runs. Resume interrupted runs from
checkpoints. Compact long threads automatically.
Multi-Agent
Orchestrate subagent DAGs with fan-out/fan-in, join policies, and
backpressure controls.
LLM Layer
Provider-portable LLM runtime with retry, circuit breaking, caching, rate
limiting, and fallback chains.
Observability
Built-in telemetry pipeline with spans, metrics, and exporters for console,
JSON, and OpenTelemetry.
Evals
Behavioral testing framework with assertions, budgets, golden traces, and
CI-ready reporting.
Security
Policy engine, sandbox profiles, tool allowlists, A2A auth, and secret scope
isolation out of the box.