Build Your Own Coding Agent in 21 Days
Course questions · 63 / 63
101 more tagsShow fewer tags
D1 What Layers Make Up a Coding Agent: the REPL Skeleton, the Command System, and a Provider-Neutral Gateway Abstraction
How would you layer a terminal coding agent, and which layer must never be polluted by a vendor SDK?把一个终端 Coding Agent 分层,你会怎么切?哪一层最不该让厂商 SDK 渗进来?
Common in ChinaCommon overseasBasic#architecture#agent-loop🔒 Unlock D1 to see the answer keys.
Vendors ship official SDKs, so why write your own gateway layer? When does that layer become a liability?模型厂商都提供了官方 SDK,为什么还要自己写一层网关抽象?什么时候这层是负担?
Common in ChinaCommon overseasIntermediate#provider-abstraction#architecture🔒 Unlock D1 to see the answer keys.
How do you make a CLI that leans heavily on a paid model API developable and testable without any API key?一个重度依赖付费模型 API 的命令行工具,怎么做到没有密钥也能开发和测试?
Common in ChinaCommon overseasIntermediate#testing#developer-experience🔒 Unlock D1 to see the answer keys.
D2 Streaming Output and Terminal Rendering: Hand-Writing an SSE Parser, Incremental Markdown, and an Interruptible Typewriter
What edge cases bite you when hand-writing an SSE parser, and why can't you just read line by line?手写一个 SSE 解析器,有哪些容易踩的边界条件?为什么不能直接按行读?
Common in ChinaCommon overseasBasic#sse#streaming🔒 Unlock D2 to see the answer keys.
A streaming response dies halfway through. How should the client handle it, and what does retrying actually cost?流式响应在中途断开,客户端该怎么处理?重试的代价是什么?
Common in ChinaCommon overseasDeep dive#streaming#error-handling🔒 Unlock D2 to see the answer keys.
What makes incremental Markdown rendering in a terminal hard, and how do you trade correctness against responsiveness?在终端里做增量 Markdown 渲染,难点在哪?正确性与实时性冲突时你怎么权衡?
Common in ChinaCommon overseasIntermediate#terminal-ui#streaming🔒 Unlock D2 to see the answer keys.
D3 The Tool Protocol and the Read-Only Trio: Schema Design, Chunk Merging, and Result Truncation
How do you write a tool's description and JSON Schema so the model gets it right more often?工具的描述与 JSON Schema 该怎么写,才能让模型少犯错?
Common in ChinaCommon overseasBasic#tool-design#json-schema🔒 Unlock D3 to see the answer keys.
How do you reassemble streamed tool-call arguments, and which assumptions are off-limits?流式返回的工具调用参数怎么归并?有哪些假设是不能做的?
Common in ChinaCommon overseasDeep dive#tool-calling#streaming🔒 Unlock D3 to see the answer keys.
When a tool result blows past your context budget, what is your truncation strategy, and how do you avoid cutting the part that matters?工具结果远超上下文预算时,你的截断策略是什么?怎么保证不截掉关键信息?
Common in ChinaCommon overseasIntermediate#context-budget#tool-design🔒 Unlock D3 to see the answer keys.
D4 File Editing and Shell Execution: Exact-Match Replacement, Conflict Detection, and a Timeout-Killable Subprocess
To let a model edit files, do you pick whole-file rewrite, exact string replacement, or patches? Why?让模型改文件,你会选整文件重写、精确替换还是补丁?为什么?
Common in ChinaCommon overseasBasic#file-editing#tool-design🔒 Unlock D4 to see the answer keys.
How does an edit tool detect conflicts, and what should it tell the model when detection fails?编辑工具怎么做冲突检测?检测失败时该给模型什么信息?
Common in ChinaCommon overseasIntermediate#file-editing#conflict-detection🔒 Unlock D4 to see the answer keys.
What constraints do you put on running arbitrary shell commands from an agent, and how do you actually kill one after a timeout?在 Agent 里执行任意 shell 命令,你会加哪些约束?超时之后怎么真正把它杀掉?
Common in ChinaCommon overseasDeep dive#shell-execution#process-management🔒 Unlock D4 to see the answer keys.
D5 Permissions and Approval: a Three-State Rule Set, Matching by Tool and Path, and the Boundaries of Auto Mode
Designing an agent's permission model: which states do you need, what do rules match on, and which rule wins when several match?设计一个 Agent 的权限模型,你需要哪几种状态?规则按什么匹配、命中多条时听谁的?
Common in ChinaCommon overseasIntermediate#permissions#agent-design🔒 Unlock D5 to see the answer keys.
The user rejects a tool call. How does the loop continue, and why not just throw?用户拒绝了一次工具调用,循环该怎么继续?为什么不能直接抛错?
Common in ChinaCommon overseasDeep dive#approval#agent-loop🔒 Unlock D5 to see the answer keys.
When is it acceptable to run an agent fully autonomously, and what preconditions do you require?什么情况下可以给 Agent 开全自动模式?你会要求哪些前置条件?
Common in ChinaCommon overseasIntermediate#autonomy#safety🔒 Unlock D5 to see the answer keys.
D6 Error Handling and Self-Correction: Feeding Failures Back, Backoff Retries, Loop Detection, and Cancellation
How do you classify errors at agent runtime? Which ones go back to the model to self-correct, and which surface to the user?Agent 运行时的错误怎么分类?哪些该回灌给模型让它自纠,哪些该直接报给用户?
Common in ChinaCommon overseasBasic#error-handling#agent-loop🔒 Unlock D6 to see the answer keys.
How would you implement retries and backoff? Why add jitter, and which errors must never be retried?重试与退避你会怎么实现?为什么要加抖动?哪些错误绝对不该重试?
Common in ChinaCommon overseasIntermediate#retry#backoff🔒 Unlock D6 to see the answer keys.
When the user presses cancel, which layers must the cancellation signal reach before things have really stopped?用户按下取消,你的取消信号要穿过哪几层才算真的停下来?
Common in ChinaCommon overseasDeep dive#cancellation#subprocess🔒 Unlock D6 to see the answer keys.
D7 Session Persistence and Recovery: an Append-Only Event Log, Resume and Forking, Week One Retrospective
For session persistence, would you use an append-only event log or store a session snapshot? What does each cost?会话持久化你选事件日志还是存会话快照?各自的代价是什么?
Common in ChinaCommon overseasBasic#persistence#event-log🔒 Unlock D7 to see the answer keys.
How does an append-only log handle a last line that was cut off mid-write?只追加的日志怎么处理写到一半崩掉的最后一行?
Common in ChinaCommon overseasIntermediate#durability#event-log🔒 Unlock D7 to see the answer keys.
What is the difference between forking a new session at some point in history and rolling back to that point?从历史某一步分叉出一条新会话,和回滚到那一步有什么区别?
Common in ChinaCommon overseasDeep dive#fork#session-state🔒 Unlock D7 to see the answer keys.
D8 Reference Injection: Parsing @ Files, Directories, URLs, and Images, and Accounting for What Got Injected
Implementing file-reference injection (an @ syntax, say), how would you handle directories, binary files, and very large files?实现文件引用注入(比如 @ 语法),你会怎么处理目录、二进制文件和超大文件?
Common in ChinaCommon overseasBasic#context-injection#file-handling🔒 Unlock D8 to see the answer keys.
When injected context exceeds its budget, how do you trim it, and should the trimming rules be visible to the user?注入的上下文超过预算怎么裁?裁剪规则要不要让用户可见?
Common in ChinaCommon overseasIntermediate#context-budget#trimming🔒 Unlock D8 to see the answer keys.
When should you push content into the context yourself, and when should you let the model fetch it with tools?什么时候该主动把内容塞进上下文,什么时候该让模型自己调工具去取?
Common in ChinaCommon overseasDeep dive#context-strategy#retrieval🔒 Unlock D8 to see the answer keys.
D9 Project Instruction Files: Three-Tier Loading, Import Expansion, and the System Prompt's Merge Order
For layered project instruction files, how do you decide precedence, and who wins on a conflict?分层的项目指令文件,优先级怎么定?冲突时谁赢?
Common in ChinaCommon overseasBasic#layered-config#system-prompt🔒 Unlock D9 to see the answer keys.
If instruction files can import one another, what safety limits would you add?指令文件支持互相导入,你会加哪些安全限制?
Common in ChinaCommon overseasIntermediate#imports#safety-limits🔒 Unlock D9 to see the answer keys.
How do you make the final system prompt explainable to the user, and why is that worth doing?怎么让最终的 system prompt 对用户可解释?为什么这件事值得做?
Common in ChinaCommon overseasDeep dive#observability#prompt-assembly🔒 Unlock D9 to see the answer keys.
D10 Task Lists and Self-Planning: the Todo Tool, Progress Rendering, and Early Detection of Spinning
What does letting the model maintain its own task list buy you over writing the plan in the prompt, and what does it cost?让模型自己维护任务清单,比在提示词里写计划好在哪?代价是什么?
Common in ChinaCommon overseasBasic#self-planning#tool-design🔒 Unlock D10 to see the answer keys.
With streaming text and a fixed progress area in the same terminal, how do you manage the cursor and repaints?终端里同时有流式文本和固定的进度区域,你怎么管光标与刷新?
Common in ChinaCommon overseasIntermediate#terminal-rendering#cursor-control🔒 Unlock D10 to see the answer keys.
How do you detect from runtime data that an agent is spinning in place, and what do you do once you detect it?怎么从运行数据里发现 Agent 已经在打转?发现之后怎么干预?
Common in ChinaCommon overseasDeep dive#stall-detection#agent-observability🔒 Unlock D10 to see the answer keys.
D11 Cross-Session Memory: Explicit Memory, Automatic Memory, and Three Criteria for Retrieval Injection
What problem does an agent's memory solve, versus conversation history and project instruction files?Agent 的记忆和会话历史、项目指令文件分别解决什么问题?
Common in ChinaCommon overseasBasic#agent-memory#context-design🔒 Unlock D11 to see the answer keys.
How do you retrieve memories so that only the relevant ones get injected, and how would you define relevance?记忆怎么检索才能只注入相关的?相关性判据你会怎么定?
Common in ChinaCommon overseasIntermediate#memory-retrieval#context-injection🔒 Unlock D11 to see the answer keys.
What must never go into long-term memory, and how do you detect that a memory has gone stale?哪些内容绝不该写进长期记忆?记忆过期了怎么发现?
Common in ChinaCommon overseasDeep dive#memory-hygiene#secret-redaction🔒 Unlock D11 to see the answer keys.
D12 Context Compression: How to Count Tokens, What to Compress and What to Keep, and How to Verify Nothing Was Lost
Without pulling in a tokenizer, how would you estimate the token count of a context? How large is the error, and when must you not rely on an estimate?不引入分词器,你怎么估算一段上下文有多少 token?误差有多大,什么时候不能用估算?
Common in ChinaCommon overseasBasic#token-counting#calibration🔒 Unlock D12 to see the answer keys.
When compacting context, which kinds of messages must be kept verbatim, and which are the safest to compress away?做上下文压缩时,哪几类消息必须原样保留?压掉哪些最安全?
Common in ChinaCommon overseasIntermediate#context-compaction#keep-list🔒 Unlock D12 to see the answer keys.
How do you prove that a context compaction did not lose critical information?怎么证明一次上下文压缩没有丢掉关键信息?
Common in ChinaCommon overseasDeep dive#compaction-verification#probes🔒 Unlock D12 to see the answer keys.
D13 Ask Before Acting: a Structured Question Tool, a Read-Only Exploration Mode, and Plan Approval
When should an agent stop and ask the user a question? What does asking too much cost, and what does never asking cost?什么时候 Agent 该停下来反问用户?问得太多和不问各有什么代价?
Common in ChinaCommon overseasBasic#clarification#human-in-the-loop🔒 Unlock D13 to see the answer keys.
How would you implement plan mode, and what is its relationship to the permission system?计划模式怎么实现?它和权限系统是什么关系?
Common in ChinaCommon overseasIntermediate#plan-mode#permissions🔒 Unlock D13 to see the answer keys.
After a plan is approved, how do you ensure the execution did not drift from it?批准了一份计划之后,怎么保证执行没有偏离?
Common in ChinaCommon overseasDeep dive#plan-verification#drift-detection🔒 Unlock D13 to see the answer keys.
D14 Checkpoints and Rewind: File Snapshots, Conversation Rollback, and Why the Two Must Stay Independent
How would you design an agent's file snapshots, and why not just make git commits?Agent 的文件快照怎么设计?为什么不直接用 git 提交?
Common in ChinaCommon overseasBasic#snapshots#content-addressing🔒 Unlock D14 to see the answer keys.
Why must file rollback and conversation rewind be separate? What happens when you rewind only one of them?文件回滚和对话回退为什么要分开?只回一边会发生什么?
Common in ChinaCommon overseasIntermediate#rewind#two-timelines🔒 Unlock D14 to see the answer keys.
Before a rewind you find uncommitted changes in the workspace, or a file that was modified externally. How do you handle it?回滚前发现工作区有未提交改动,或者文件被外部改过,你怎么处理?
Common in ChinaCommon overseasDeep dive#workspace-safety#dirty-state🔒 Unlock D14 to see the answer keys.
D15 Wiring Up MCP: a Hand-Written JSON-RPC Client, Two Transports, and a Tool Namespace
If you hand-write an MCP client without the official SDK, which protocol details do you have to handle yourself?不用官方 SDK 手写一个 MCP 客户端,你必须自己处理哪些协议细节?
Common in ChinaCommon overseasBasic#json-rpc#mcp-client🔒 Unlock D15 to see the answer keys.
When would you use the stdio transport versus Streamable HTTP, and how do their failure modes differ?stdio 与 Streamable HTTP 两种传输分别适合什么场景?它们的失败方式有什么不同?
Common in ChinaCommon overseasIntermediate#transports#stdio-vs-http🔒 Unlock D15 to see the answer keys.
What governance would you put in place before aggregating third-party MCP server tools into your own agent?把第三方 MCP server 的工具聚合进自己的 Agent,你会加哪些治理措施?
Common in ChinaCommon overseasDeep dive#trust-boundary#tool-governance🔒 Unlock D15 to see the answer keys.
D16 Loading Skills: Scanning, Progressive Disclosure, and Trigger Judgment — Bringing Experience to the Table on Demand
How many stages does progressive disclosure for skills have, and what triggers each one?技能的渐进披露具体分几个阶段?每个阶段的判据是什么?
Common in ChinaCommon overseasBasic#progressive-disclosure#skills🔒 Unlock D16 to see the answer keys.
Where is the line between a skill and a tool, and how do you decide which one a given capability should be?技能和工具的边界在哪?同一件事你怎么决定做成技能还是做成工具?
Common in ChinaCommon overseasIntermediate#skills-vs-tools#agent-design🔒 Unlock D16 to see the answer keys.
How would you design skill trigger conditions, and which is harder to diagnose - over-triggering or under-triggering?技能的触发条件怎么设计?过度触发和漏触发哪个更难查?
Common in ChinaCommon overseasDeep dive#trigger-design#false-positives🔒 Unlock D16 to see the answer keys.
D17 Subagents and Parallelism: Independent Context, a Tool Allowlist, Worktree Isolation, and Result Aggregation
What should a subagent inherit from the main session, and what must it never inherit?子 Agent 该继承主会话的什么、绝不该继承什么?
Common in ChinaCommon overseasBasic#subagent#context-boundary🔒 Unlock D17 to see the answer keys.
How do you isolate parallel agents editing one repository, and how are conflicts detected and handled?并行改同一个仓库,你用什么手段隔离?冲突怎么发现和处理?
Common in ChinaCommon overseasIntermediate#worktree#merge-conflict🔒 Unlock D17 to see the answer keys.
Which tasks are worth dispatching to subagents, and which get worse when parallelized?什么任务适合派给子 Agent,什么任务并行反而更差?
Common in ChinaCommon overseasDeep dive#parallelism-cost#agent-design🔒 Unlock D17 to see the answer keys.
D18 Hooks and Background Tasks: Lifecycle Hooks, Deterministic Checks, and Notifications That Don't Interrupt the Conversation
Which constraints belong in hooks and which belong in the prompt? What is the criterion?哪些约束该用钩子实现,哪些该写进提示词?判据是什么?
Common in ChinaCommon overseasBasic#hooks#prompt-engineering#agent-design🔒 Unlock D18 to see the answer keys.
How do you design hooks so they can veto a call without deadlocking the agent?钩子怎么设计才能既能否决又不至于把 Agent 卡死?
Common in ChinaCommon overseasDeep dive#hooks#reliability#failure-handling🔒 Unlock D18 to see the answer keys.
When a long-running command goes to the background, how do its status and result get back into the session?长时间运行的命令放到后台,状态与结果怎么回到会话里?
Common in ChinaCommon overseasIntermediate#background-tasks#async#terminal-ux🔒 Unlock D18 to see the answer keys.
D19 Multimodal Input: Pasting Screenshots, Image Validation, and Fixing Code From a Screenshot
How would you add images to an existing text-only message schema without breaking compatibility?在已有的纯文本消息结构上加图片,你会怎么改才不破坏兼容?
Common in ChinaCommon overseasBasic#multimodal#message-schema🔒 Unlock D19 to see the answer keys.
What validation does image input need, and why would a very small image be rejected?图片输入要做哪些校验?为什么小图片会被拒绝?
Common in ChinaCommon overseasIntermediate#input-validation#multimodal🔒 Unlock D19 to see the answer keys.
How do you design the fallback when a model cannot see images, and how do you find out that it cannot?模型不支持图片时的降级策略怎么设计?你怎么先知道它不支持?
Common in ChinaCommon overseasDeep dive#capability-detection#graceful-degradation🔒 Unlock D19 to see the answer keys.
D20 Evaluation and Cost: Designing a Benchmark Set, Computing Pass Rate, and Reading Token Usage and Cache Hits
How do you design a benchmark set for a coding agent, and should the grader look at the end state or at the process?怎么给一个 Coding Agent 设计基准集?判分函数该看终态还是过程?
Common in ChinaCommon overseasBasic#benchmark-design#grading🔒 Unlock D20 to see the answer keys.
Which metrics would you use to judge a coding agent, and why is pass rate not enough?你会用哪几个指标衡量一个 Coding Agent 的好坏?为什么通过率不够?
Common in ChinaCommon overseasIntermediate#metrics#cost#cache🔒 Unlock D20 to see the answer keys.
Results for the same task vary between runs. How do you tell whether a change actually helped, given that noise?同一道题多次运行结果不稳定,你怎么在这种噪声下判断一次改动是不是真的有效?
Common in ChinaCommon overseasDeep dive#variance#ab-testing#evaluation🔒 Unlock D20 to see the answer keys.
D21 Packaging and Release: a Global Command, a Config Directory, Versioning and Updates — a Twenty-One-Day Retrospective
What is easy to overlook when shipping a command line tool as a globally installable package?把一个命令行工具发布成可全局安装的包,有哪些容易忽略的坑?
Common in ChinaCommon overseasIntermediate#packaging#cli#distribution🔒 Unlock D21 to see the answer keys.
How do you decide the layering and override order of configuration, and where should secrets live?配置的分层与覆盖顺序你怎么定?密钥该放哪里?
Common in ChinaCommon overseasIntermediate#configuration#secrets#cli🔒 Unlock D21 to see the answer keys.
If you put this hand-built coding agent on your resume, how would you convey its technical substance in three sentences?把这个自己实现的 Coding Agent 写进简历,你会怎么用三句话说清它的技术含量?
Common in ChinaCommon overseasDeep dive#portfolio#communication#agent-engineering🔒 Unlock D21 to see the answer keys.