Book companion

AgentOS Reader Resources

Book illustrations, source code, a quick start, chapter guides, updates and errata for Enterprise AgentOS Architecture Design and Engineering Practice by Jiayu Xu.

Cover of Enterprise AgentOS Architecture Design and Engineering Practice
Published · Tsinghua University Press

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. 1. The first Agent

    • agentos_lab/first_agent.py
    python agentos_lab/agentos_lab/first_agent.py

    Standard library only; prints a simulated purchase recommendation.

  2. 2. Object contracts

    • agentos_lab/domain.py
    • agentos_lab/schema_export.py
    • object_contract/
    uv run --project agentos_lab python -m agentos_lab.main framework schemas --json

    Exports core object contracts; object_contract/ contains a separate handwritten validation example.

  3. 3. Task runtime

    • agentos_lab/runtime.py
    • agentos_lab/graph_compat.py
    • agentos_lab/langgraph_api.py
    uv run --project agentos_lab python -m agentos_lab.main run purchase --case write-timeout --json

    Exercises a purchase timeout locally; LangGraph requires the optional runtime dependencies.

  4. 4. Model gateway

    • model_gateway/
    • agentos_lab/model_router.py
    • agentos_lab/litellm_gateway.py
    uv run --project agentos_lab python agentos_lab/model_gateway/route_demo.py --case purchase_budget_limit

    Local budget fallback decision; does not call a model provider.

  5. 5. Tool protocols

    • agentos_lab/fastmcp_adapter.py
    • agentos_lab/protocols.py
    • agentos_lab/connectors.py
    uv run --project agentos_lab python -m agentos_lab.main framework fastmcp --json

    Shows tool contracts and framework mappings; does not establish a remote MCP connection.

  6. 6. Data and evidence

    • agentos_lab/knowledge.py
    • agentos_lab/data_engine.py
    • agentos_lab/llamaindex_context.py
    uv run --project agentos_lab python -m agentos_lab.main run document --json

    Runs the local document case; standalone context_evidence/ examples include preset fields.

  7. 7. Policies and permissions

    • agentos_lab/policy.py
    • agentos_lab/control_plane.py
    • agentos_lab/opa_policy.py
    uv run --project agentos_lab python -m agentos_lab.main run purchase --case permission-denied --json

    Exercises permission denial; actual OPA execution requires a separately configured service.

  8. 8. Traces and testing

    • agentos_lab/trace_export.py
    • agentos_lab/otel_observability.py
    • agentos_lab/evaluations.py
    • tests/
    uv run --project agentos_lab python -m agentos_lab.main trace purchase --case write-timeout --json

    Inspects local execution traces without a telemetry backend.

  9. 9. Long-running task recovery

    • runtime_queue/local_queue.py
    • run_purchase_task.py
    • send_approval.py
    • workers/purchase_worker.py
    • query_task.py
    python agentos_lab/run_purchase_task.py --task purchase-demo

    Submit first, then approve, process and query using the recovery walkthrough below; uses local SQLite without Temporal. Full recovery walkthrough

  10. 10. System composition

    • agentos_lab/system.py
    • agentos_lab/registry.py
    • composition/
    uv run --project agentos_lab python -m agentos_lab.main run all --json

    Runs core scenarios; preset composition/ and composition_walkthrough/ outputs are not integration verification.

  11. 11. Purchase and equipment cases

    • agentos_lab/runtime.py
    • agentos_lab/operations_runtime.py
    • agentos_lab/casebook.py
    uv run --project agentos_lab python -m agentos_lab.main run service --case stale-knowledge --json

    Exercises stale equipment documentation and blocks writeback; use run purchase --case erp-conflict --json for purchase conflicts.

  12. 12. Platform operations

    • platform_registry/
    • agentos_lab/backstage_catalog.py
    • agentos_lab/benchmark.py
    python agentos_lab/platform_registry/validate_catalog.py

    Checks 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.