Enterprise AgentOS Architecture Design and Engineering Practice
By Jiayu Xu · Chinese-language edition
ISBN 978-7-302-72747-7
Start with a first Agent and build toward object contracts, task runtimes, model gateways, tools and evidence, approvals, traces and long-running task recovery. AgentOS is the book's reference architecture and engineering method.
Book illustrations
89 illustrations from the final 12-chapter text, organized by the book's figure numbers and captions.
Complete figure PDF · 24.3 MiB SHA-256
Illustrations are hosted on this site. Complete Cloudflare verification before downloading. PDFs are moderately compressed and link back to the author's website from the cover and every page footer. The collection contains illustrations, figure numbers and captions, without the book's body text.
Source download
Integrated companion source · 2026-09-10 · 12 chapters
Download companion source ZIP Download SHA-256 file
GitHub: AgentOS-Lab companion source · Report an issue · Repository code is available under the MIT license.
Size: 373285 bytes (about 365 KiB). Includes a usage guide and one agentos_lab project.
SHA-256: 495c230f5cddedb29dec7e09f0a803dd997191ee8595a68af936c0887c0287c5
The archive uses the earlier title 《从零搭建企业级 AgentOS》. This is the original delivery archive; this page uses the published title. Follow the directory structure and usage guide inside the download.
Quick start
Requires Python 3.10+. Open a terminal in the extracted folder containing the usage guide.
1. Run the first Agent
Uses only the Python standard library; prints a simulated purchase recommendation without writing to an ERP.
python agentos_lab/agentos_lab/first_agent.py
2. Install dependencies and run the purchase case
Install uv first. The initial dependency installation requires internet access.
uv sync --project agentos_lab --locked
uv run --project agentos_lab python -m agentos_lab.main run purchase --case normal --json
Default cases need no model API key or enterprise account. Companies, ERP, OA and business data are simulated. Real models, remote MCP, OPA, Temporal and telemetry backends require extra configuration; framework commands show local interface mappings.
3. Explore long-running task recovery
python agentos_lab/run_purchase_task.py --task purchase-demo
python agentos_lab/send_approval.py --task purchase-demo
python agentos_lab/workers/purchase_worker.py
python agentos_lab/query_task.py --task purchase-demo
Run these commands in order from the same directory; they share .agentos-demo/tasks.sqlite3. The worker processes the approved task and the query should return completed. Repeated processing does not create duplicate simulated purchase records. Use a new task ID for a new exercise.
Chapter code guide
File paths are relative to the outer agentos_lab/ folder; run commands from the extracted root folder.
-
1. The first Agent
agentos_lab/first_agent.py
python agentos_lab/agentos_lab/first_agent.pyStandard library only; prints a simulated purchase recommendation.
-
2. Object contracts
agentos_lab/domain.pyagentos_lab/schema_export.pyobject_contract/
uv run --project agentos_lab python -m agentos_lab.main framework schemas --jsonExports core object contracts; object_contract/ contains a separate handwritten validation example.
-
3. Task runtime
agentos_lab/runtime.pyagentos_lab/graph_compat.pyagentos_lab/langgraph_api.py
uv run --project agentos_lab python -m agentos_lab.main run purchase --case write-timeout --jsonExercises a purchase timeout locally; LangGraph requires the optional runtime dependencies.
-
4. Model gateway
model_gateway/agentos_lab/model_router.pyagentos_lab/litellm_gateway.py
uv run --project agentos_lab python agentos_lab/model_gateway/route_demo.py --case purchase_budget_limitLocal budget fallback decision; does not call a model provider.
-
5. Tool protocols
agentos_lab/fastmcp_adapter.pyagentos_lab/protocols.pyagentos_lab/connectors.py
uv run --project agentos_lab python -m agentos_lab.main framework fastmcp --jsonShows tool contracts and framework mappings; does not establish a remote MCP connection.
-
6. Data and evidence
agentos_lab/knowledge.pyagentos_lab/data_engine.pyagentos_lab/llamaindex_context.py
uv run --project agentos_lab python -m agentos_lab.main run document --jsonRuns the local document case; standalone context_evidence/ examples include preset fields.
-
7. Policies and permissions
agentos_lab/policy.pyagentos_lab/control_plane.pyagentos_lab/opa_policy.py
uv run --project agentos_lab python -m agentos_lab.main run purchase --case permission-denied --jsonExercises permission denial; actual OPA execution requires a separately configured service.
-
8. Traces and testing
agentos_lab/trace_export.pyagentos_lab/otel_observability.pyagentos_lab/evaluations.pytests/
uv run --project agentos_lab python -m agentos_lab.main trace purchase --case write-timeout --jsonInspects local execution traces without a telemetry backend.
-
9. Long-running task recovery
runtime_queue/local_queue.pyrun_purchase_task.pysend_approval.pyworkers/purchase_worker.pyquery_task.py
python agentos_lab/run_purchase_task.py --task purchase-demoSubmit first, then approve, process and query using the recovery walkthrough below; uses local SQLite without Temporal. Full recovery walkthrough
-
10. System composition
agentos_lab/system.pyagentos_lab/registry.pycomposition/
uv run --project agentos_lab python -m agentos_lab.main run all --jsonRuns core scenarios; preset composition/ and composition_walkthrough/ outputs are not integration verification.
-
11. Purchase and equipment cases
agentos_lab/runtime.pyagentos_lab/operations_runtime.pyagentos_lab/casebook.py
uv run --project agentos_lab python -m agentos_lab.main run service --case stale-knowledge --jsonExercises stale equipment documentation and blocks writeback; use run purchase --case erp-conflict --json for purchase conflicts.
-
12. Platform operations
platform_registry/agentos_lab/backstage_catalog.pyagentos_lab/benchmark.py
python agentos_lab/platform_registry/validate_catalog.pyChecks required catalog markers rather than full JSON Schema validation; Backstage is an object mapping, not a running platform service.
Updates & errata
Source releases and reader feedback.
2026-10-25 · Illustrations and public companion code
Added a complete PDF containing 89 illustrations from the final text, with figure numbers, captions and checksums. Companion code is now available in AgentOS-Lab for browsing and issue reports.
2026-09-10 · Integrated companion source
Brings the first Agent into a single project with a 12-chapter code guide, locked dependencies and local task recovery. The original delivery record reports 72 passing checks in each of the default and LangGraph environments on macOS arm64 with Python 3.10.16. This is a historical record, not verification of every operating system or real external service.
Errata and feedback
No confirmed errata entries have been collected here yet. Send the chapter, page, source version, command, error output and reproduction steps to xujiayu0606@gmail.com.
Further reading
Related articles in Chinese; runnable cases are available in the source archive and chapter guide above.
- MiniCode: building an AI coding assistant from scratch — Tool calling, context and permission boundaries.
- Architecture details of modern large language models — Model foundations behind the gateway.