4.0 KiB
4.0 KiB
LinkedIn Draft & Consultant Review: Slashing Agent Context and Token Churn With an AST Code Graph
文档性质:从
blog.hoelee.com改写并在 NocoDB 排期的 LinkedIn 生产级动态。 发布状态:已通过外部顾问审阅 / NocoDB 已排期待发布排期波次:Wave 1 (立威期) - 槽位 2 (拟发布日期: 2026-11-03 Tue) 源文章:https://blog.hoelee.com/posts/slashing-agent-context-with-a-code-graph/ 系统标识:slashing-agent-context-with-a-code-graph| 分类:ai字数:1995 chars (严格控制在 3,000 字符内)
一、 核心背景与铁律约束提示(供复核对照)
- 求职画像契合(Senior 全栈/DevOps/AI 架构师):彻底脱敏“做生意的老板/小公司创始人”倾向;一切商业实战均转换为“生产系统架构、高可用交付与自动化运维”视角。
- 纯洁人设与零禁用词:绝对禁止
homelab,home lab,家用,小主机,玩具,折腾,玩票等词汇。必须使用the infrastructure I manage,my self-hosted production nodes,production host。 - 第一人称单数:统一使用单数
I/我,杜绝虚张声势的复数we。 - 数据绝对保真:所有数字、性能比率、吞吐提升、故障现象严禁凭空捏造。
- OPSEC 安全脱敏:无内部绝对路径(如
D:/dev),无真实私有内网 IP,公网 IP 必须转为文档保留地址。
二、 LinkedIn 拟发布动态文案(已按顾问意见修订)
When you prompt an AI coding agent to modify a 50,000-line codebase, its default instinct is brute force: grep directories and recursively dump dozens of files into context.
The result is instant token bankruptcy:
• Reading 25 files to trace one dependency consumes 40,000+ tokens in a single turn.
• High-context saturation triggers cognitive degradation — models start hallucinating method signatures and missing subtle type contracts.
I tested three conventional fixes, and all of them failed under real development conditions:
1. Ripgrep keyword filtering: Zero semantic awareness. A search for `processOrder` matches comments, test mocks, and logging across 60 files. The agent still had to open 15 files just to find the implementation.
2. Vector RAG embeddings: Excellent for fuzzy concepts, useless for deterministic code trees. Vector similarity regularly misses internal helper functions (like `_verifyNonce`), leading agents to generate patches with nonexistent signatures.
3. File outline skeletons: Lacks parameter types and caller hierarchies, forcing speculative full-file reads anyway.
The durable fix: A pre-indexed AST Code Knowledge Graph.
Before the agent touches the code, an external parser extracts the repository's Abstract Syntax Tree into a symbol graph of callers, callees, definitions, and interface implementations.
• When the agent needs to inspect a function, it queries the graph and receives an exact 140-token node (signature, parameter types, caller list).
• Instead of dumping 3,000 lines of code across 5 files, the agent targets its read exclusively to the specific 25 lines that require mutation.
Across 20 production tickets, AST code graphs reduced agent context overhead by ~80% and eliminated 100% of signature hallucination errors.
How is your team balancing deterministic AST symbol graphs with semantic search when building context pipelines for coding agents?
Write-up: https://blog.hoelee.com/posts/slashing-agent-context-with-a-code-graph/
三、 外部顾问审阅评估反馈单与归档记录
- 审阅结论:通过
- 1. 诊断与修改批注:零违规,数据边界清晰,展现一流 AI 平台架构功底,直接排期发布。
- 2. NocoDB 归档记录:
- Candidate Key:
cand:slashing-agent-context-with-a-code-graph(Status:APPROVED, Priority:HIGH) - Draft Key:
cand:slashing-agent-context-with-a-code-graph:v1(Status:APPROVED) - 拟定发布节奏:每周 2 篇(周二/周四),平稳推进 5 周。
- Candidate Key: