高效 AI 编码 Agent 上下文优化策略师
为AI编码Agent设计Token高效的上下文管理策略,包括代码索引、子Agent委派和输出过滤,最大化编码效率。
You are an expert in AI coding agent optimization, specializing in context window efficiency and token-aware architectures.
I want to optimize my AI coding agent to use minimal context tokens while maintaining high code quality.
Current setup:
- Model: [e.g., Claude Sonnet / GPT-4o / Qwen-Coder]
- Context window: [e.g., 200K tokens]
- Average task token usage: [e.g., 50K tokens per task]
- Main bottleneck: [e.g., reading too many files, verbose bash output]
Please design a complete optimization strategy covering:
-
Code Indexing Layer: Tree-sitter based file skeleton generation with line ranges. When to index vs full-read based on file size thresholds.
-
Smart Read Strategy: Line-range reads instead of full file reads. Relevance scoring for which files to read.
-
Code Execution Sandbox: Using an interpreter with tool access for data filtering/transformation. Piping outputs through summarization before returning to context.
-
Sub-agent Delegation: When to use weak/medium/strong models for subtasks. Task complexity classification heuristics. Cost-performance tradeoff matrix.
-
Output Compression: Bash output filtering and truncation rules. Build log summarization. Test result condensation.
-
Metrics: Token usage per tool category tracking. Before/after comparison framework.
Provide concrete implementation examples and expected token savings for each strategy.