The AI thinks, the gate decides — how I made LLM code edits deterministic (and cut token usage 42×)
说明与用途
D‑Engine 通过将LLM思考与本地确定性编辑分离,减少 44 倍的 token 使用并防止不安全的提交。
问题
AI coding agents consume excessive tokens and risk breaking code due to lack of memory, state drift, and atomic writes.
结果
D‑Engine achieved token usage 44× lower than dsh, comparable quality (48/50 points), and prevented unsafe commits, demonstrating that a stricter gate outperforms smarter agents.
工作流
- 1. Selector step: LLM picks minimal relevant files (≈300 tokens).
- 2. Proposal step: LLM generates SEARCH/REPLACE patches (≈2,000 tokens).
- 3. LocalEditor applies patches via 4‑strategy cascade.
- 4. Compiler validates patched copy.
- 5. commitAndMerge stages only touched files if gate green.
- 6. (Optional) Verify mode: send modified snippet for semantic audit (330–984 tokens).
证据
D-Engine (my harness) 2,552 tokens, ~4 s vs dsh 107,000 tokens, 28 s
The model receives only those files and generates the SEARCH/REPLACE blocks.
D-Engine Fast ~2,100 tokens per task, dsh ~93,000 tokens for same set.
- 记录日期: 2026-09-15T20:30:47.385Z