Unit 3 of 10 · about 5 hours · implement

Reconstructing an unfamiliar AI application from code, configuration and traces

Your own architecture is familiar enough to hide assumptions. LLM gives you a real, smaller application in which to verify those assumptions from code rather than a diagram.

You'll be able to

  • Reconstruct a pinned application's command, adapter, tool, history and migration paths from source and test observations.
  • Distinguish implemented guarantees from absent retrieval, tenant policy and production evaluation layers.
  • Produce a source-to-trace map that identifies one reviewable extension point.

Covers

Reconstructing an unfamiliar AI application from code, configuration and traces
1

Read

In this order, only the parts listed

0 of 2 done

  1. LLM 0.36: entry points and endpoint adapterLLM (command-line tool and library), pinned

    Commit 2465dfc: pyproject.toml project scripts; llm/cli.py function cli; openai_models.py nested command endpoint and Chat.execute; llm/plugins.py function load_plugins

    Follow the Chat Completions endpoint path first. Skip provider inventories and unrelated commands. Read docs/other-models.md, OpenAI-compatible models, for the command's public contract.

  2. State, logs and selected public testsLLM (command-line tool and library), pinned

    test_openai_endpoint.py, test_migrate.py, test_pause_resume.py and test_tools.py; follow their calls into llm/models.py, llm/logs.py and llm/migrations.py

    Run these four files, not the whole suite. Use Python 3.13, OpenAI 3.33.0, Pydantic 2.14.1, httpx2 2.13.1, sqlite-utils 4.2.1, pytest 9.1.1, pytest-asyncio 1.4.0, httpx2-pytest 2.0.0 and llm-echo 0.3a3; install the remaining test dependencies declared by the pinned project and lock the resolved environment.

2

Focus on

  • Follow command registration, validated options, message construction, model response consumption, tool dispatch and optional persistence. Do not infer a database write from a database import.
  • The direct endpoint command does not log prompts or forward the configured default OpenAI key. Ordinary prompting has a different logging path; map both before changing persistence.
  • Plugins and Python tools are executable trusted code. A tool confirmation prompt is not a multi-tenant authorization service.
  • Mark absent paths explicitly. This endpoint path does not supply agentlab's permission-aware retrieval, durable business-effect ledger or release evaluation.
Common mistakes · 3
  • Reading only the default CLI command when the chosen integration uses the direct endpoint command. Their persistence and key behavior differ.
  • Treating a mocked endpoint test as evidence of model quality or local-server compatibility. It proves only its stated adapter behavior.
  • Installing arbitrary plugins to explore the application. Importing a plugin executes code before any model output is reviewed.
3

Try it yourself

Closed-book, before checking anything

From the pinned checkout, run python -m pytest tests/test_openai_endpoint.py tests/test_migrate.py tests/test_pause_resume.py tests/test_tools.py -q. The baseline has 94 passing tests with the stated environment, on CPU without provider calls. Closed-book, trace test_endpoint_chat_completions_does_not_log_or_leak_default_key from the CLI to the mocked request and back. Predict its request body, dummy authorization header and absent log database before checking the assertions. Compare this with a logged response's migration and history path.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why does the endpoint test set a fake default API key?Answer

    It checks that a configured default key is not forwarded to the chosen endpoint: the captured request uses Bearer DUMMY_KEY instead. It does not test every explicit credential option.

  2. 2.Does a passing migration suite prove safe downgrade?Answer

    No. It checks specified upgrades and schema properties. Old-binary reads of new data and rollback compatibility require separate tests.

  3. 3.Where should missing tenant enforcement appear in your reconstruction?Answer

    As an absent boundary requiring an application-owned control, not as an imagined guarantee of the CLI, model or plugin system.

5

Practice

  • LLM 0.36: four-file reconstruction baseline

    Run test_openai_endpoint.py, test_migrate.py, test_pause_resume.py and test_tools.py with the pinned test dependencies

    Keep the baseline output and annotate one assertion per path with its owning function. The tests use mocks, echo responses and recorded fixtures; no hosted key is required. The section mini-project adds the source-to-trace reconstruction.

You're done when

The four-file baseline passes and your map links a request, a tool result and a persisted history record to actual functions and tests, with missing product controls marked.

Only when you can do this without notes.

Leads to

Notes

Resources · 1 for this unit, 9 more in the section
  • LLM (command-line tool and library), pinnedSimon Willison · required

    At commit 2465dfc (version 0.36), trace the path from llm.cli:cli through the OpenAI-compatible adapter in llm/default_plugins/openai_models.py to llm/models.py, llm/logs.py and llm/migrations.py. Run tests/test_openai_endpoint.py, test_migrate.py, test_pause_resume.py and test_tools.py on CPU, point llm openai endpoint at your local server, then make one bounded, tested change such as versioned usage normalization or a tool-chain budget, with a migration and a secret-free replay fixture.

Also in this section

  • AI Engineering and Agentic Systems CheckpointRoadmap-Final · primary

    Execute the complete checkpoint now: explain ownership, derive budgets and contracts, pass versioned evaluation, prove tenant isolation and replay safety, red-team the system, measure the joint frontier, then reconstruct and modify a production-like application.

  • Evidence-Grounded Retrieval SystemRoadmap-Final · required

    Close the deferred clauses: Milestones B (instrumentation), D (injected failure attribution), E (paired optimization) and F (blinded query and delete campaign with a clean rebuild), the correctness requirements and the rubric. Index rollback and an honest negative result are this track's additions, not project headings.

  • Durable Tool-Using WorkflowRoadmap-Final · required

    Close Milestones B, D, E and F and the correctness requirements: crash-window replay, approval bound to the exact effect, fencing, ambiguous outcomes surfaced instead of claimed exactly-once, the matched deterministic, routed and agentic comparison, and clean reproduction. Finish the existing system rather than rebuilding it; delegation stays optional.

  • AI Product Architecture Case StudiesEngineering Handbook · support

    Pick two of case studies 8.30 to 8.33 (ChatGPT, Enterprise RAG, Coding Agent, Perplexity Search; slugs chatgpt-conversational-ai, enterprise-rag, coding-agent, perplexity-ai-search), reconstruct each decomposition, identify its hidden assumptions and compare it with yours. Recompute the capacity tables before trusting a number: several are wrong (8.31's per-tenant index cost, 8.33's daily query volume).

  • AI and ML System Design HandbookEngineering Handbook · reference

    Part 9 chapters 0 to 8 are overview-depth architecture notes for serving, RAG, vector search, agents, evaluation, LLMOps, cost and safety. Use them as a checklist for omissions in the integrated design; serving (00, 02) belongs to the Inference track.

  • Managing Incidents and Incident ResponseGoogle SRE · support

    Read SRE book Chapter 14 (elements of incident management, when to declare an incident) and Workbook Chapter 9 Incident Response with its case studies. Write the incident procedure for the integrated system and run it once against an injected fault.

  • AI Agents in Depth - Integration ReviewBojie Li · support

    Use 5.1.4 harness engineering, 7.9 and 7.10 and Chapter 9 (9.3.2 safety boundaries for continual evolution, Experiment 9-6 canary and rollback) as a final review. The offline chapter9/harness-safety-gate tests (no API key) show a release gate that rejects a seeded bad candidate.

  • The Hitchhiker's Guide to Agentic AI - ProductionHaggai Roitman · support

    Use v3 Chapter 27 (27.5 testing, 27.6 observability, 27.7 deployment) and 28.7 human-in-the-loop UI to audit the integrated system. Verify claims against official documentation.

  • AI Engineering Handbook - AI Product EngineeringHandbook Academy · support

    Use Part 11 to connect evaluation and system evidence to product decisions, feedback and iteration. Finish with a decision memo that distinguishes model capability, orchestration, retrieval, tool, evaluator and user-experience effects.