Skip to content

Part 2 · Python In-Process Embedding

The shortest integration path for Python hosts: from agentao import Agentao and drive the runtime with method calls — no protocol overhead.

Key terms in this Part

Five vocabulary items you'll see throughout — bookmark Appendix G for the full glossary.

  • Agentao instance — one constructor call → one stateful session; close() is mandatory · §2.3, G.1
  • Working directory (cwd) — file-tool root, MCP cwd, AGENTAO.md lookup; frozen at construction · §2.2, G.1
  • Transport — push-style callback (emit(event)) for streaming UI · §2.7, G.2
  • CancellationToken — host-side handle to abort an in-flight chat() · §2.6, G.1
  • extra_mcp_servers — per-session MCP injection (different tenants → different tokens) · §2.2

Coverage

Read by task

What you're doing nowShortest path
Embed the Python SDK in a script2.1 Install & Import2.2 Minimum constructor params2.3 Standard lifecycle
Wire it into a FastAPI / Flask product2.7 Production template2.6 Cancellation & timeouts2.4 Session state
Build multi-tenant / multi-session pooling2.2 Constructor params2.4 Session state2.7 Session-pool template
Look up a specific API2.2 Constructor Reference or Appendix A · API Reference

Before you start

Make sure you've read:

Mental model

An agent is not a function call — it is a stateful process component. One Agentao(...) == one session. Many sessions → many instances. close() is mandatory, not polite.

Start with 2.1 →