# 与《从 LLM 到 Coding Agent》对照总表

> 把《从 LLM 到 Coding Agent》里讲过的每个概念，对到 Grok Build 的具体 crate 与本专栏对应章节——一张「教学最小实现 ↔ 生产实现」的索引表，两本配对着读用它当地图。

- 作者：David（道雾轩）
- 专栏：Grok Build 源码解读（https://daiw.org/manual/grok-build.md）
- 最后更新：2026-09-15
- 原文：https://daiw.org/manual/grok-build/pairing-map
- 转载与引用：请注明出处并附原文链接（https://daiw.org/about/copyright）

# 与《从 LLM 到 Coding Agent》对照总表

这本专栏的一个核心读法，是和 [《从 LLM 到 Coding Agent》](https://daiw.org/manual/llm-to-agent) 配对：那本把每个概念拆到**教学最小实现**，这本看它们在 grok 里的**生产实现**。这一章给你一张对照表当索引——想深挖某个概念时，两边一起翻。

## 概念 ↔ crate ↔ 章节

| 概念 | 《从 LLM 到 Coding Agent》 | Grok Build 的实现 | 本专栏 |
| --- | --- | --- | --- |
| Agent 主循环 | [agent-loop](https://daiw.org/manual/llm-to-agent/agent-loop) | `xai-grok-shell`（`SessionActor`、`turn.rs`）+ `xai-grok-agent`（Agent 对象） | 第 1 部分 |
| 裸 LLM API | [raw-llm-api](https://daiw.org/manual/llm-to-agent/raw-llm-api) | `xai-grok-sampler` + `xai-grok-sampling-types` | 第 1 部分 |
| 流式输出 | [streaming](https://daiw.org/manual/llm-to-agent/streaming) | `sampler/stream/*` | 第 1 部分 |
| 流式工具执行 | [streaming-tool-execution](https://daiw.org/manual/llm-to-agent/streaming-tool-execution) | sampler 事件 + tools 路由 | 第 1、2 部分 |
| 工具用法 | [tool-use](https://daiw.org/manual/llm-to-agent/tool-use) | `xai-grok-tools` | 第 2 部分 |
| 工具抽象 | [tool-abstraction](https://daiw.org/manual/llm-to-agent/tool-abstraction) | `xai-tool-protocol` + `tools/types` | 第 2 部分 |
| thinking / 推理 | [thinking](https://daiw.org/manual/llm-to-agent/thinking) | `xai-grok-sampler` | 第 1 部分 |
| 会话历史 | [session-history](https://daiw.org/manual/llm-to-agent/session-history) | `xai-chat-state` | 第 1 部分 |
| prompt 缓存 | [prompt-caching](https://daiw.org/manual/llm-to-agent/prompt-caching) | `sampling-types` 请求构造 | 第 1 部分 |
| 权限 | [permissions](https://daiw.org/manual/llm-to-agent/permissions) | `xai-grok-sandbox` + `xai-grok-workspace`（`permission/`） | 第 2 部分 |
| 打断 | [interrupt](https://daiw.org/manual/llm-to-agent/interrupt) | `xai-interjection-core` | 第 1 部分 |
| 错误恢复 | [error-recovery](https://daiw.org/manual/llm-to-agent/error-recovery) | `sampler/retry.rs` + `tools/retry` + `xai-circuit-breaker` | 第 1、2 部分 |
| 上下文注入 | [context-injection](https://daiw.org/manual/llm-to-agent/context-injection) | `xai-grok-agent/prompt/*` | 第 1 部分 |
| 上下文压缩 | [context-compaction](https://daiw.org/manual/llm-to-agent/context-compaction) | `xai-grok-compaction` | 第 1 部分 |
| 自动压缩 | [auto-compaction](https://daiw.org/manual/llm-to-agent/auto-compaction) | `xai-grok-shell`（`session/compaction.rs`）+ `xai-grok-agent/compaction.rs` | 第 1 部分 |
| token 预算 | [token-budget](https://daiw.org/manual/llm-to-agent/token-budget) | `xai-token-estimation` + telemetry | 第 1、6 部分 |
| subagents | [subagents](https://daiw.org/manual/llm-to-agent/subagents) | `xai-grok-subagent-resolution` | 第 4 部分 |
| hooks | [hooks](https://daiw.org/manual/llm-to-agent/hooks) | `xai-grok-hooks` | 第 4 部分 |
| MCP | [mcp](https://daiw.org/manual/llm-to-agent/mcp) | `xai-grok-mcp` | 第 4 部分 |
| 成本追踪 | [cost-tracking](https://daiw.org/manual/llm-to-agent/cost-tracking) | `xai-chat-state`（`usage.rs`）+ `xai-grok-telemetry` | 第 6 部分 |

## grok 多出来的部分

上表是「两本都讲」的交集。而 grok 作为一个**成品**，还有一大块是教学最小实现不会碰、但真实产品必须做的——这也是这本专栏在对照之外的增量：

- **终端 UI**：一个完整的 TUI（滚动缓冲、实时 markdown、diff 可视化、主题）——第 5 部分。
- **代码库理解**：workspace 抽象 + 代码库图谱 + 文件监听——第 3 部分。
- **并行与隔离**：`fast-worktree` 隔离执行、subagent 并行、OS 级 sandbox——第 2、3、4 部分。
- **编辑器嵌入**：ACP 协议，让 grok 当 IDE 的后端——第 6 部分。
- **分发与扩展生态**：plugins + marketplace、skills、自定义模型——第 4 部分。
- **工程底座**：proto/codegen、遥测、崩溃处理、自更新——第 6 部分。

## 怎么用这张表

- 如果你**已经读过** llm-to-agent：直接查表，跳到你想看「生产实现」的那个概念对应的部分。
- 如果你**没读过**：也能独立读这本，但遇到某个概念想补「最小实现」的直觉，就点表里的链接过去对照。

<Callout type="info">
  一句话记住两本的分工：llm-to-agent 回答「**为什么要这样做、最简怎么做**」，这本回答「**真做成产品会长什么样**」。
</Callout>

---

上一篇：[Rust workspace 全景](https://daiw.org/manual/grok-build/workspace-map) · 下一篇：[读源码前的准备](https://daiw.org/manual/grok-build/reading-the-source)
