Writing
Building an Agent is a 28-part series: start from the plainest LLM call, add one capability per part, and keep going until the system can be secured, costed, deployed, tested and maintained. Written in Chinese; titles and summaries here are translated.
手搓 Agent
28 articles · in series order2026.10.07Session 01: from LLM to agent — when the model starts choosing the next stepStart from the simplest LLM call and add one capability at a time, until the program decides its own next step.2026.10.09Session 02: scaling tools — cost, selection and maintenanceOnce an agent has dozens of tools, the hard problems stop being prompts: they become cost, selection and maintenance.2026.10.09Session 03: context engineering, part 1 — what does the LLM actually see?Every call sends a finite context to the model. Knowing exactly what lands in it is the precondition for controlling it.2026.10.10Session 03: context engineering, part 2 — managing a context that keeps growingContext grows with every turn. Trimming, summarising and re-assembling it is a system design problem, not a prompt trick.2026.10.13Session 04: memory — making the agent remember what actually mattersNot all history deserves to survive. Memory is a filtering problem with a write path, a read path and a cost model.2026.10.13Session 05: planning — adjusting the plan from execution resultsA plan that cannot be revised is a script. Planning means reading the result and deciding what to change next.2026.10.14Session 06: reflection — checking the result before moving onFinishing the steps is not the same as getting the result right. Reflection adds a check before the workflow moves on.2026.10.14Session 07: RAG and knowledge — retrieving and using external materialRetrieval is easy to demo and hard to make dependable: chunking, recall, relevance, and the cost of stuffing results into context.2026.10.14Session 08: workflow — making the agent follow a fixed sequenceWhen order matters, hand the sequence to edges instead of asking the model to remember it.2026.10.14Session 09: multi-agent — splitting work across cooperating agentsSplitting work across agents buys specialisation and isolation, and pays for it in coordination cost.2026.10.14Session 10: agent runtime — making the loop run reliablyThe runtime is where the loop stops being a demo: streaming, timeouts, cancellation and resource limits.2026.10.20Session 11: human-in-the-loop — pausing where a person must decideSome actions must not be taken by the model alone. Interrupt, show the result, wait for a decision, then resume.2026.10.21Session 12: MCP — wiring a hand-built agent to standardised capabilitiesMCP standardises how external capabilities are described and called, so tools stop being bespoke glue code.2026.10.21Session 13: skills — reusable procedures the agent can loadA skill packages a procedure the agent can load on demand, instead of keeping every instruction in the system prompt.2026.10.19Session 14: agent security — who actually guarantees safety?Prompt-level safety is not a boundary. Security has to be enforced where permissions and data actually live.2026.10.19Session 15: guardrails — constraints the system can enforceGuardrails are constraints the system enforces: schema validation, allow-lists, quotas and hard stops.2026.10.19Session 16: error handling — what happens after the agent failsFailure semantics decide whether the agent retries, degrades or asks for help — and what the user finally sees.2026.10.19Session 17: model APIs — the interface and the call mechanicsThe model API is a contract: tokens, streaming, tool calls, stop reasons and errors all shape the design.2026.10.19Session 18: model routing — choosing a model per requestRouting sends each request to a model that fits its difficulty, latency budget and price.2026.10.19Session 19: context optimization — the same task, fewer tokensMost context is spent on things the model does not need this turn. Cutting them is cheaper than upgrading the model.2026.10.19Session 20: caching — reuse instead of recomputationCaching agent work is harder than caching HTTP: the key includes the prompt, the tools and the state.2026.10.19Session 21: cost and latency — where the money and the milliseconds goA cheap model called ten times is not cheap. Cost and latency are properties of the whole task.2026.10.20Session 22: deployment — the runtime architecture of an agent serviceDeployment decides whether the agent survives restarts, traffic and long-running tasks.2026.10.20Session 23: persistence — state storage and task recoveryCheckpoints turn a conversation into a recoverable state machine.2026.10.20Session 24: testing — how to test an agent systemAgent tests need deterministic tools and recorded model responses, otherwise every run is a different experiment.2026.10.20Session 25: evaluation — measuring what the agent actually deliversEvaluation is about whether the outcome was right, not whether the response looked plausible.2026.10.20Session 26: debugging — locating and diagnosing agent failuresDebugging means reading the trace: which tool ran, what it returned, and where the context went wrong.2026.10.20Session 28: architecture — designing an agent system you can maintainArchitecture is what keeps the loop from becoming one 800-line function: boundaries, state and failure paths.