--- name: context-budgeting description: Manager context small, raw data to files, token estimation workflow for the orchestrator agent. tags: ['management', 'context', 'tokens'] --- # Context Budgeting ## Purpose Keep the main agent's context small by storing raw data in files and using includes/references instead of inline data. ## When to Use - When a tool returns more than 80 lines of text - When the user provides large files for processing - When the conversation history grows large - When a subordinate returns a long report ## When Not to Use - For short tool outputs (< 30 lines) - For data that must be reasoned about inline ## Procedure 1. Receive large output from tool or subordinate 2. Save to a file (e.g., /a0/usr/workdir/.md) 3. Reference the file in the response: `See §include(/path/to/file.md)` 4. Optionally summarize the file in a few lines for context 5. Use raw file only when deep analysis is needed ## Token Estimation Rule - 1 line of code/markdown ≈ 10-20 tokens - 80 lines of tool output ≈ 1000-1500 tokens - 1000 lines of conversation ≈ 15000-20000 tokens - Compress when output exceeds 1000 tokens ## See Also - Tool: `context_compactor` (plugin tool for structured compression)