21 天手搓一个 Coding Agent
课程题库 · 63 / 63 道题
还有 101 个标签收起标签
D1 一个 Coding Agent 由哪几层组成:REPL 骨架、命令系统与不绑厂商的网关抽象
把一个终端 Coding Agent 分层,你会怎么切?哪一层最不该让厂商 SDK 渗进来?How would you layer a terminal coding agent, and which layer must never be polluted by a vendor SDK?
国内高频海外高频基础#architecture#agent-loop🔒 解锁 D1 后查看答题要点。
模型厂商都提供了官方 SDK,为什么还要自己写一层网关抽象?什么时候这层是负担?Vendors ship official SDKs, so why write your own gateway layer? When does that layer become a liability?
国内高频海外高频进阶#provider-abstraction#architecture🔒 解锁 D1 后查看答题要点。
一个重度依赖付费模型 API 的命令行工具,怎么做到没有密钥也能开发和测试?How do you make a CLI that leans heavily on a paid model API developable and testable without any API key?
国内高频海外高频进阶#testing#developer-experience🔒 解锁 D1 后查看答题要点。
D2 流式输出与终端渲染:手写 SSE 解析、增量 Markdown 与可打断的打字机
手写一个 SSE 解析器,有哪些容易踩的边界条件?为什么不能直接按行读?What edge cases bite you when hand-writing an SSE parser, and why can't you just read line by line?
国内高频海外高频基础#sse#streaming🔒 解锁 D2 后查看答题要点。
流式响应在中途断开,客户端该怎么处理?重试的代价是什么?A streaming response dies halfway through. How should the client handle it, and what does retrying actually cost?
国内高频海外高频深入#streaming#error-handling🔒 解锁 D2 后查看答题要点。
在终端里做增量 Markdown 渲染,难点在哪?正确性与实时性冲突时你怎么权衡?What makes incremental Markdown rendering in a terminal hard, and how do you trade correctness against responsiveness?
国内高频海外高频进阶#terminal-ui#streaming🔒 解锁 D2 后查看答题要点。
D3 工具协议与只读三件套:schema 设计、分片归并与结果截断
工具的描述与 JSON Schema 该怎么写,才能让模型少犯错?How do you write a tool's description and JSON Schema so the model gets it right more often?
国内高频海外高频基础#tool-design#json-schema🔒 解锁 D3 后查看答题要点。
流式返回的工具调用参数怎么归并?有哪些假设是不能做的?How do you reassemble streamed tool-call arguments, and which assumptions are off-limits?
国内高频海外高频深入#tool-calling#streaming🔒 解锁 D3 后查看答题要点。
工具结果远超上下文预算时,你的截断策略是什么?怎么保证不截掉关键信息?When a tool result blows past your context budget, what is your truncation strategy, and how do you avoid cutting the part that matters?
国内高频海外高频进阶#context-budget#tool-design🔒 解锁 D3 后查看答题要点。
D4 文件编辑与 shell 执行:精确替换、冲突检测与超时可杀的子进程
让模型改文件,你会选整文件重写、精确替换还是补丁?为什么?To let a model edit files, do you pick whole-file rewrite, exact string replacement, or patches? Why?
国内高频海外高频基础#file-editing#tool-design🔒 解锁 D4 后查看答题要点。
编辑工具怎么做冲突检测?检测失败时该给模型什么信息?How does an edit tool detect conflicts, and what should it tell the model when detection fails?
国内高频海外高频进阶#file-editing#conflict-detection🔒 解锁 D4 后查看答题要点。
在 Agent 里执行任意 shell 命令,你会加哪些约束?超时之后怎么真正把它杀掉?What constraints do you put on running arbitrary shell commands from an agent, and how do you actually kill one after a timeout?
国内高频海外高频深入#shell-execution#process-management🔒 解锁 D4 后查看答题要点。
D5 权限与审批:三态规则、按工具与路径匹配,以及自动模式的边界
设计一个 Agent 的权限模型,你需要哪几种状态?规则按什么匹配、命中多条时听谁的?Designing an agent's permission model: which states do you need, what do rules match on, and which rule wins when several match?
国内高频海外高频进阶#permissions#agent-design🔒 解锁 D5 后查看答题要点。
用户拒绝了一次工具调用,循环该怎么继续?为什么不能直接抛错?The user rejects a tool call. How does the loop continue, and why not just throw?
国内高频海外高频深入#approval#agent-loop🔒 解锁 D5 后查看答题要点。
什么情况下可以给 Agent 开全自动模式?你会要求哪些前置条件?When is it acceptable to run an agent fully autonomously, and what preconditions do you require?
国内高频海外高频进阶#autonomy#safety🔒 解锁 D5 后查看答题要点。
D6 错误处理与自纠:失败回灌、退避重试、死循环检测与取消中断
Agent 运行时的错误怎么分类?哪些该回灌给模型让它自纠,哪些该直接报给用户?How do you classify errors at agent runtime? Which ones go back to the model to self-correct, and which surface to the user?
国内高频海外高频基础#error-handling#agent-loop🔒 解锁 D6 后查看答题要点。
重试与退避你会怎么实现?为什么要加抖动?哪些错误绝对不该重试?How would you implement retries and backoff? Why add jitter, and which errors must never be retried?
国内高频海外高频进阶#retry#backoff🔒 解锁 D6 后查看答题要点。
用户按下取消,你的取消信号要穿过哪几层才算真的停下来?When the user presses cancel, which layers must the cancellation signal reach before things have really stopped?
国内高频海外高频深入#cancellation#subprocess🔒 解锁 D6 后查看答题要点。
D7 会话持久化与恢复:只追加的事件日志、resume 与分叉,第一周复盘
会话持久化你选事件日志还是存会话快照?各自的代价是什么?For session persistence, would you use an append-only event log or store a session snapshot? What does each cost?
国内高频海外高频基础#persistence#event-log🔒 解锁 D7 后查看答题要点。
只追加的日志怎么处理写到一半崩掉的最后一行?How does an append-only log handle a last line that was cut off mid-write?
国内高频海外高频进阶#durability#event-log🔒 解锁 D7 后查看答题要点。
从历史某一步分叉出一条新会话,和回滚到那一步有什么区别?What is the difference between forking a new session at some point in history and rolling back to that point?
国内高频海外高频深入#fork#session-state🔒 解锁 D7 后查看答题要点。
D8 引用注入:解析 @ 文件、目录、URL 与图片,并把注入量说清楚
实现文件引用注入(比如 @ 语法),你会怎么处理目录、二进制文件和超大文件?Implementing file-reference injection (an @ syntax, say), how would you handle directories, binary files, and very large files?
国内高频海外高频基础#context-injection#file-handling🔒 解锁 D8 后查看答题要点。
注入的上下文超过预算怎么裁?裁剪规则要不要让用户可见?When injected context exceeds its budget, how do you trim it, and should the trimming rules be visible to the user?
国内高频海外高频进阶#context-budget#trimming🔒 解锁 D8 后查看答题要点。
什么时候该主动把内容塞进上下文,什么时候该让模型自己调工具去取?When should you push content into the context yourself, and when should you let the model fetch it with tools?
国内高频海外高频深入#context-strategy#retrieval🔒 解锁 D8 后查看答题要点。
D9 项目指令文件:三层加载、导入展开与 system prompt 的合并顺序
分层的项目指令文件,优先级怎么定?冲突时谁赢?For layered project instruction files, how do you decide precedence, and who wins on a conflict?
国内高频海外高频基础#layered-config#system-prompt🔒 解锁 D9 后查看答题要点。
指令文件支持互相导入,你会加哪些安全限制?If instruction files can import one another, what safety limits would you add?
国内高频海外高频进阶#imports#safety-limits🔒 解锁 D9 后查看答题要点。
怎么让最终的 system prompt 对用户可解释?为什么这件事值得做?How do you make the final system prompt explainable to the user, and why is that worth doing?
国内高频海外高频深入#observability#prompt-assembly🔒 解锁 D9 后查看答题要点。
D10 任务清单与自我规划:todo 工具、进度渲染与打转的早期发现
让模型自己维护任务清单,比在提示词里写计划好在哪?代价是什么?What does letting the model maintain its own task list buy you over writing the plan in the prompt, and what does it cost?
国内高频海外高频基础#self-planning#tool-design🔒 解锁 D10 后查看答题要点。
终端里同时有流式文本和固定的进度区域,你怎么管光标与刷新?With streaming text and a fixed progress area in the same terminal, how do you manage the cursor and repaints?
国内高频海外高频进阶#terminal-rendering#cursor-control🔒 解锁 D10 后查看答题要点。
怎么从运行数据里发现 Agent 已经在打转?发现之后怎么干预?How do you detect from runtime data that an agent is spinning in place, and what do you do once you detect it?
国内高频海外高频深入#stall-detection#agent-observability🔒 解锁 D10 后查看答题要点。
D11 跨会话记忆:显式记忆、自动记忆与检索注入的三个判据
Agent 的记忆和会话历史、项目指令文件分别解决什么问题?What problem does an agent's memory solve, versus conversation history and project instruction files?
国内高频海外高频基础#agent-memory#context-design🔒 解锁 D11 后查看答题要点。
记忆怎么检索才能只注入相关的?相关性判据你会怎么定?How do you retrieve memories so that only the relevant ones get injected, and how would you define relevance?
国内高频海外高频进阶#memory-retrieval#context-injection🔒 解锁 D11 后查看答题要点。
哪些内容绝不该写进长期记忆?记忆过期了怎么发现?What must never go into long-term memory, and how do you detect that a memory has gone stale?
国内高频海外高频深入#memory-hygiene#secret-redaction🔒 解锁 D11 后查看答题要点。
D12 上下文压缩:token 怎么数、压什么留什么、压完怎么验证没丢
不引入分词器,你怎么估算一段上下文有多少 token?误差有多大,什么时候不能用估算?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-counting#calibration🔒 解锁 D12 后查看答题要点。
做上下文压缩时,哪几类消息必须原样保留?压掉哪些最安全?When compacting context, which kinds of messages must be kept verbatim, and which are the safest to compress away?
国内高频海外高频进阶#context-compaction#keep-list🔒 解锁 D12 后查看答题要点。
怎么证明一次上下文压缩没有丢掉关键信息?How do you prove that a context compaction did not lose critical information?
国内高频海外高频深入#compaction-verification#probes🔒 解锁 D12 后查看答题要点。
D13 先问后做:结构化提问工具、只读探索模式与计划审批
什么时候 Agent 该停下来反问用户?问得太多和不问各有什么代价?When should an agent stop and ask the user a question? What does asking too much cost, and what does never asking cost?
国内高频海外高频基础#clarification#human-in-the-loop🔒 解锁 D13 后查看答题要点。
计划模式怎么实现?它和权限系统是什么关系?How would you implement plan mode, and what is its relationship to the permission system?
国内高频海外高频进阶#plan-mode#permissions🔒 解锁 D13 后查看答题要点。
批准了一份计划之后,怎么保证执行没有偏离?After a plan is approved, how do you ensure the execution did not drift from it?
国内高频海外高频深入#plan-verification#drift-detection🔒 解锁 D13 后查看答题要点。
D14 checkpoint 与 rewind:文件快照、对话回退,以及两者为什么必须独立
Agent 的文件快照怎么设计?为什么不直接用 git 提交?How would you design an agent's file snapshots, and why not just make git commits?
国内高频海外高频基础#snapshots#content-addressing🔒 解锁 D14 后查看答题要点。
文件回滚和对话回退为什么要分开?只回一边会发生什么?Why must file rollback and conversation rewind be separate? What happens when you rewind only one of them?
国内高频海外高频进阶#rewind#two-timelines🔒 解锁 D14 后查看答题要点。
回滚前发现工作区有未提交改动,或者文件被外部改过,你怎么处理?Before a rewind you find uncommitted changes in the workspace, or a file that was modified externally. How do you handle it?
国内高频海外高频深入#workspace-safety#dirty-state🔒 解锁 D14 后查看答题要点。
D15 接入 MCP:手写 JSON-RPC 客户端、两种传输与工具命名空间
不用官方 SDK 手写一个 MCP 客户端,你必须自己处理哪些协议细节?If you hand-write an MCP client without the official SDK, which protocol details do you have to handle yourself?
国内高频海外高频基础#json-rpc#mcp-client🔒 解锁 D15 后查看答题要点。
stdio 与 Streamable HTTP 两种传输分别适合什么场景?它们的失败方式有什么不同?When would you use the stdio transport versus Streamable HTTP, and how do their failure modes differ?
国内高频海外高频进阶#transports#stdio-vs-http🔒 解锁 D15 后查看答题要点。
把第三方 MCP server 的工具聚合进自己的 Agent,你会加哪些治理措施?What governance would you put in place before aggregating third-party MCP server tools into your own agent?
国内高频海外高频深入#trust-boundary#tool-governance🔒 解锁 D15 后查看答题要点。
D16 加载 Skills:扫描、渐进披露与触发判定,让经验按需上桌
技能的渐进披露具体分几个阶段?每个阶段的判据是什么?How many stages does progressive disclosure for skills have, and what triggers each one?
国内高频海外高频基础#progressive-disclosure#skills🔒 解锁 D16 后查看答题要点。
技能和工具的边界在哪?同一件事你怎么决定做成技能还是做成工具?Where is the line between a skill and a tool, and how do you decide which one a given capability should be?
国内高频海外高频进阶#skills-vs-tools#agent-design🔒 解锁 D16 后查看答题要点。
技能的触发条件怎么设计?过度触发和漏触发哪个更难查?How would you design skill trigger conditions, and which is harder to diagnose - over-triggering or under-triggering?
国内高频海外高频深入#trigger-design#false-positives🔒 解锁 D16 后查看答题要点。
D17 子 Agent 与并行:独立上下文、工具白名单、worktree 隔离与结果汇总
子 Agent 该继承主会话的什么、绝不该继承什么?What should a subagent inherit from the main session, and what must it never inherit?
国内高频海外高频基础#subagent#context-boundary🔒 解锁 D17 后查看答题要点。
并行改同一个仓库,你用什么手段隔离?冲突怎么发现和处理?How do you isolate parallel agents editing one repository, and how are conflicts detected and handled?
国内高频海外高频进阶#worktree#merge-conflict🔒 解锁 D17 后查看答题要点。
什么任务适合派给子 Agent,什么任务并行反而更差?Which tasks are worth dispatching to subagents, and which get worse when parallelized?
国内高频海外高频深入#parallelism-cost#agent-design🔒 解锁 D17 后查看答题要点。
D18 hooks 与后台任务:生命周期钩子、确定性检查与不打断对话的通知
哪些约束该用钩子实现,哪些该写进提示词?判据是什么?Which constraints belong in hooks and which belong in the prompt? What is the criterion?
国内高频海外高频基础#hooks#prompt-engineering#agent-design🔒 解锁 D18 后查看答题要点。
钩子怎么设计才能既能否决又不至于把 Agent 卡死?How do you design hooks so they can veto a call without deadlocking the agent?
国内高频海外高频深入#hooks#reliability#failure-handling🔒 解锁 D18 后查看答题要点。
长时间运行的命令放到后台,状态与结果怎么回到会话里?When a long-running command goes to the background, how do its status and result get back into the session?
国内高频海外高频进阶#background-tasks#async#terminal-ux🔒 解锁 D18 后查看答题要点。
D19 多模态输入:粘贴截图、图片校验与照图改代码
在已有的纯文本消息结构上加图片,你会怎么改才不破坏兼容?How would you add images to an existing text-only message schema without breaking compatibility?
国内高频海外高频基础#multimodal#message-schema🔒 解锁 D19 后查看答题要点。
图片输入要做哪些校验?为什么小图片会被拒绝?What validation does image input need, and why would a very small image be rejected?
国内高频海外高频进阶#input-validation#multimodal🔒 解锁 D19 后查看答题要点。
模型不支持图片时的降级策略怎么设计?你怎么先知道它不支持?How do you design the fallback when a model cannot see images, and how do you find out that it cannot?
国内高频海外高频深入#capability-detection#graceful-degradation🔒 解锁 D19 后查看答题要点。
D20 评估与成本:基准集怎么设计、通过率怎么算、token 与缓存命中怎么看
怎么给一个 Coding Agent 设计基准集?判分函数该看终态还是过程?How do you design a benchmark set for a coding agent, and should the grader look at the end state or at the process?
国内高频海外高频基础#benchmark-design#grading🔒 解锁 D20 后查看答题要点。
你会用哪几个指标衡量一个 Coding Agent 的好坏?为什么通过率不够?Which metrics would you use to judge a coding agent, and why is pass rate not enough?
国内高频海外高频进阶#metrics#cost#cache🔒 解锁 D20 后查看答题要点。
同一道题多次运行结果不稳定,你怎么在这种噪声下判断一次改动是不是真的有效?Results for the same task vary between runs. How do you tell whether a change actually helped, given that noise?
国内高频海外高频深入#variance#ab-testing#evaluation🔒 解锁 D20 后查看答题要点。
D21 打包与发布:全局命令、配置目录、版本与更新,二十一天总复盘
把一个命令行工具发布成可全局安装的包,有哪些容易忽略的坑?What is easy to overlook when shipping a command line tool as a globally installable package?
国内高频海外高频进阶#packaging#cli#distribution🔒 解锁 D21 后查看答题要点。
配置的分层与覆盖顺序你怎么定?密钥该放哪里?How do you decide the layering and override order of configuration, and where should secrets live?
国内高频海外高频进阶#configuration#secrets#cli🔒 解锁 D21 后查看答题要点。
把这个自己实现的 Coding Agent 写进简历,你会怎么用三句话说清它的技术含量?If you put this hand-built coding agent on your resume, how would you convey its technical substance in three sentences?
国内高频海外高频深入#portfolio#communication#agent-engineering🔒 解锁 D21 后查看答题要点。