Repository navigation
Description
Description
autoCompact is on by default (60% of the model limit, source/config/index.ts loadAutoCompactConfig). Docs (docs/features/context-compression.md) talk like it is a product-wide behaviour.
It only runs in the interactive TUI loop. performAutoCompact is called from processAssistantResponse in source/hooks/chat-handler/conversation/conversation-loop.tsx (around 551), after the assistant message is committed.
These paths never call it:
source/plain/conversation.ts(~168)client.chatfor--plain/nanocoder runsource/acp/acp-conversation.ts(~183) ACP / VS Code / Zedsource/subagents/subagent-executor.ts(~436)client.chat(messages)with no cap and no compact
Plain and ACP do use capMessagesForModel (count, default 1000). Subagents do not even do that. Token budget is ignored everywhere except the TUI.
Local Ollama / 8k models in nanocoder run, editor ACP, and delegated subagents will keep stuffing tool results until the provider 400s. The setting in agents.config.json does nothing there.
Use Case
CI / --plain job on a small local model. Daemon skill that launches a subagent. VS Code ACP session. Same autoCompact config, none of those loops honour it.
Proposed Solution
Call the existing helper. Do not write a second compressor.
- After each assistant turn on the three loops, call
performAutoCompactthe same way the TUI does (messages, system message, tokenizer /getModelContextLimit, native tool defs). - Subagents also pass through
capMessagesForModelbeforeclient.chat. Plain and ACP already do. - Mechanical strategy if LLM compact is too heavy for a tiny subagent. Reuse
autoCompact.strategy. No new config key required for v1.
Tests: fixture that is over threshold on the plain loop compact; subagent history longer than maxMessages is sliced without orphaning tool rows (message-capping.ts already walks back).
Alternatives Considered
- Leave it as TUI-only. Then the default config is a lie for
--plain, ACP, and subagents, which is most of the local-first story. - Fold this into [Feature] Semantic Context Compiler (Intelligent Context Budget Management) #793. 793 is send-time stubs / a compiler. This is wiring a function that already exists. Smaller and shippable alone.
- Truncate harder per tool (
truncateToolResult). Already done. Does not replace history compact on long loops.
Additional Context
- I have searched existing issues to ensure this is not a duplicate (Feature Request: Add "/compact" Command for Context Compression #13 shipped TUI auto-compact; [Bug] performAutoCompact fails when using Qwen on premise #525 was context-limit detection, closed)
- This feature aligns with the project's goals (local-first AI assistance)
Happy to take this if assigned.
Activity
Dhirenderchoudhary commentedon Aug 29, 2026
@akramcodez can I take this one?
looked at current main first so we are not duplicating.
happy to start once assigned.
akramcodez commentedon Aug 30, 2026
sure @Dhirenderchoudhary
fix: restore TUI auto-compact and stop the message cap truncating his…