V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
pDJJq
V2EX  ›  Claude

[开源][ClaudeCode] 通过 SubAgent 实现 Augment Context Engine! 节约 83%的上下文!

  •  
  •   pDJJq · 6 天前 · 306 次点击

    https://github.com/TokenRollAI/cc-plugin

    核心实现:

    1. Scout Agnet (做大量的读取, 并且最终组织为一个精简高价值的输出): https://github.com/TokenRollAI/cc-plugin/blob/main/agents/scout.md
    2. Scout Command(强化 Agent 的调用/并行调用): https://github.com/TokenRollAI/cc-plugin/blob/main/commands/withScout.md

    原理

    https://docs.claude.com/en/docs/claude-code/sub-agents

    sub-agent 的上下文非常独立, 不影响主 agent 的进行. 非常适合做大量的 读 -> 总结 的操作.

    正如帖子所说: https://linux.do/t/topic/1031049

    claude code 的核心问题是: 用超量的上下文解决问题, 在小规模问题上良好, 在中大型项目上表现容易爆上下文.

    或者说: 全量读带来的冗余上下文.

    注意: 这里的冗余指的是对主 Agent 的上下文冗余.

    这件事情非常适合放在 subagent 里解决!

    效果如下:

    效果

    同样的问题:项目中的 Operator 有什么作用? 数据存储和流转是怎么实现的?

    使用 subagent: 29K

    > /context
      ⎿  Context Usage
         ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛀   claude-sonnet-4-5-20250929 · 17k/200k tokens (9%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ System prompt: 2.3k tokens (1.2%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ System tools: 12.1k tokens (6.0%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Custom agents: 120 tokens (0.1%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Memory files: 2.6k tokens (1.3%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Messages: 8 tokens (0.0%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛶ Free space: 183k (91.4%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
    
    

    未使用 subagent: 83K

    > /context
      ⎿  Context Usage
         ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁   claude-sonnet-4-5-20250929 · 83k/200k tokens (42%)
         ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
         ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ System prompt: 2.3k tokens (1.2%)
         ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ System tools: 12.1k tokens (6.0%)
         ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Custom agents: 120 tokens (0.1%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Memory files: 2.6k tokens (1.3%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛁ Messages: 66.0k tokens (33.0%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶   ⛶ Free space: 117k (58.5%)
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
         ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
    

    结论

    去除掉初始 context 占用: 17K

    subagent 方案增加主 agent context: 12K 原始方案增加 context: 70K

    节约上下文: 83% !

    TODO

    1. 基于 LSP 的 symbol 粒度信息获取
    2. 更好的任务划分, 增加并行度.

    可以自行体验下, 目前看在我的工作项目中效果不错.

    点点 Star!

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2120 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 16:09 · PVG 00:09 · LAX 09:09 · JFK 12:09
    ♥ Do have faith in what you're doing.