Claude Code源代码

参考URL:

如何评价Claude Code源代码泄漏? - 卜寒兮的回答 - 知乎 https://www.zhihu.com/question/2022392127145911515/answer/2022520709964931142

总结:值得借鉴的设计模式

模式在 Claude Code 里的体现可借鉴的场景
AsyncGenerator 作为流式原语query() 的整体结构任何需要流式输出 + 可中断的 agent
分层错误恢复五层上下文压缩策略资源受限下的 long-running task
流式并发工具执行StreamingToolExecutor多工具并行调用的 agent
投机性预计算startSpeculativeClassifierCheck任何有必然后续操作的流程
工具自声明并发安全性isConcurrencySafe() 接口混合读写操作的任务编排
Forked Agent 共享缓存CacheSafeParams + compact agent需要 fork 子任务但不想丢失 prompt cache
Hook 与主循环解耦Post-sampling / stop hooks任何需要插入评估逻辑的 agent 系统

回到上面那句话:harness 编码了对”模型不能独立完成什么”的假设(“the harness itself encodes assumptions about what models cannot do independently”。)

  1. AsyncGenerator 作为流式原语: