Skip to main content

Documentation Index

Fetch the complete documentation index at: https://afk.arpan.sh/llms.txt

Use this file to discover all available pages before exploring further.

AFK is a Python 3.13+ SDK for building AI agents that need to run reliably outside a demo. You define agents, tools, policies, and memory as typed Python contracts. The runner handles the agent loop, LLM calls, tool execution, streaming, checkpoints, telemetry, and safety limits.

Choose your path

Build with AFK

Start here if you are building an application, workflow, chatbot, coding tool, or production agent on top of AFK.

Maintain AFK

Start here if you are changing AFK itself, reviewing internals, or updating public contracts.

Install

The distribution package is afk-py; the import package is afk.
python -m pip install afk-py
Set an LLM provider key before running examples:
export OPENAI_API_KEY="..."

First agent

from afk.agents import Agent
from afk.core import Runner

agent = Agent(
    name="assistant",
    model="gpt-4.1-mini",
    instructions="Answer directly with concrete detail.",
)

result = Runner().run_sync(
    agent,
    user_message="What is an error budget in SRE?",
)

print(result.final_text)
print(result.state)
What matters:
  • Agent is configuration: model, instructions, tools, policies, subagents, and defaults.
  • Runner is execution: LLM calls, tool calls, memory, streaming, checkpoints, and telemetry.
  • AgentResult is the run record: final text, terminal state, tool/subagent records, usage, and cost.

Core capabilities

Agents

Declarative agent definitions with instructions, tools, subagents, skills, MCP servers, and safety limits.

Runner

Sync, async, and streaming execution with lifecycle control and thread continuity.

Tools

Typed Python tools with Pydantic validation, hooks, middleware, sandboxing, and bounded output.

LLM Runtime

Provider-portable LLM clients with retries, timeouts, rate limits, caching, circuit breakers, and fallback chains.

Memory

Thread state, checkpoints, retention, compaction, and persistent stores.

Production

Evals, observability, queues, security controls, deployment guidance, and troubleshooting.

AFK skills

Install the AFK skills with Vercel’s Skills CLI when you want Codex or another supported agent to use AFK-specific guidance:
npx skills add https://github.com/arpan404/afk --skill afk-coder
npx skills add https://github.com/arpan404/afk --skill afk-maintainer
Use afk-coder when building applications with AFK. Use afk-maintainer when reviewing or changing AFK itself. See Agent Skills for details.

How AFK fits together

Next steps

Quickstart

Build one runnable agent with one typed tool.

Learn AFK in 15 Minutes

Walk through agents, tools, streaming, memory, and safety.

Examples

Find complete snippets by scenario.

API Reference

Check canonical imports, signatures, result fields, and stability rules.