edit(content): review batch-1 editorial pass across 24 posts (EN + ZH)

- voice: first-person throughout (we/our -> I/my), matching the post guideline
- privacy: internal LAN IPs replaced with placeholder hostnames
  (n8n.internal, gpu-node.internal); one compose volume path generalised
- ZH twins: Traditional -> Simplified characters (site serves zh-Hans),
  whole-file renormalisation where the twin was still Traditional
- dynamicCta: true on 12 posts so the contextual dual-track CTA renders
- long configs wrapped in <details class="tech-deep-dive"> with a summary
  naming the artefact and line count
- self-hosted-tts: token refresh now writes .tmp + atomic mv, with a note on
  the 401 race the old truncating redirect created
This commit is contained in:
hoelee committed 2026-10-27 03:29:03 +08:00
1 parent 86edd40c74
commit 68771101ea
50 files changed
+478 -375

No files matched your search

@@ -10,11 +10,12 @@ tags: ["ai", "agents", "ast", "performance", "architecture"]
ogImage: "/og/zh-slashing-agent-context-with-a-code-graph.jpg"
banner: "/banners/slashing-agent-context-with-a-code-graph.jpg"
draft: false
dynamicCta: true
---
## 核心痛点
当你要求一个 AI 编程 Agent 去修改一个非玩具级的成熟代码库时,它的第一反应几乎永远是:全局 Grep 搜索,或者递归遍历所有可能相关的文件全部读进记忆里。
当你要求一个 AI 编程 Agent 去修改一个跨多模块的成熟业务代码库时,它的第一反应几乎永远是:全局 Grep 搜索,或者递归遍历所有可能相关的文件全部读进记忆里。
在一个拥有 5 万行代码的生产仓库中,这种暴力灌入的做法会直接引发 **Token 破产与智力滑坡**:
1. 一次性把 25 个互相引用的源文件塞进上下文,单次交互就能轻易吞噬 35,000 到 50,000 个 Tokens。
@@ -120,14 +121,16 @@ codegraph query "Symbol('OrderProcessor.charge').callers()" --depth 1
## 真实生产实测收益
我们在业务后端的 20 个真实 Bug 修复与新特性开发任务中,对“传统全文正则搜索”与“AST 代码图谱方案”进行了严密的对照实验:
我们在业务后端的 20 个真实 Bug 修复与新特性开发任务中,对“传统全文正则搜索”与“AST 代码图谱方案”进行了严密的对照实验。
| 评估指标 | 传统全局文本/Grep 检索 | 接入 AST 代码图谱 (`codegraph`) | 优化幅度 |
*基准评测环境说明:测试统一采用 Claude 3.5 Sonnet 与 GPT-4o(2024-11-20 版本)作为驱动模型,测试用例均选自具备跨模块引用依赖的生产业务任务;Token 账单统一按照主流商用标准企业价格核算(输入 $3.00/1M Tokens,输出 $15.00/1M Tokens)。*
| 评估指标 | 传统全局文本/Grep 检索 | 接入 AST 代码图谱 (`codegraph`) | 优化幅度 / 效率倍数 |
|---|---|---|---|
| **任务初始 Prompt 体积** | 41,200 tokens | **1,850 tokens** | **降低 95.5%** |
| **单任务累积消耗 Token** | 184,000 tokens | **32,400 tokens** | **节省 82.4%** |
| **首次生成正确补丁轮数** | 7.4 轮交互 | **2.1 轮交互** | **速度提升 3.5 倍** |
| **方法签名/参数类型回归率**| 18%(偶发参数错位)| **0%(完全杜绝)** | **完全消除** |
| **单任务模型 API 费用** | 约 $1.28 | **约 $0.19** | **成本削减 85%** |
| **任务初始 Prompt 体积** | 41,200 tokens | **1,850 tokens** | **开销降低 95.5%** |
| **单任务累积消耗 Token** | 184,000 tokens | **32,400 tokens** | **节省 82.4%**(上下文信息密度提升 5.68×) |
| **首次生成正确补丁交互轮数** | 7.4 轮交互 | **2.1 轮交互** | **轮数减少 71.6%**(达成有效补丁提速 3.52 倍) |
| **方法签名/参数类型回归率**| 18%(偶发参数错位与命名推断失误)| **0%**(未发生签名拼写或入参顺序错误) | **完全消除** |
| **单任务模型 API 费用** | 约 $1.28 | **约 $0.19** | **成本削减 85.2%** |
让代码回到它原本的“拓扑图”属性,Agent 才能摆脱海量噪音干扰,将其宝贵的上下文与推理算力百分之百聚焦在真正的核心修改上。