Optimize token usage across provider pipeline - #17
Merged
Merged
Conversation
jberns
reviewed
May 19, 2026
Add re-exports to config/mod.rs so consumers use crate::config::Config instead of crate::config::schema::Config. Remove unused apply_model_choice and add_provider from commands/model.rs. Rename ConvConfig→ConvParams and SpawnConfig→SpawnParams since they are runtime parameter bundles, not configuration schemas. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jberns
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduces token consumption by ~65% on multi-turn sessions through five optimizations:
[read /src/main.rs: 458 lines]) before sending to the provider. Current-turn results stay full. Error results and non-zero bash exits are always kept in full to preserve diagnostic context. Full results remain on disk in SessionStore.1\t) to compact (1:), saving ~15-20% overhead per file read.system_promptchanged fromOption<String>toVec<String>. Anthropic provider gives each block its owncache_controlmarker so the stable base prompt stays cached when the context suffix changes. Other providers join the blocks.Changed files
session/compress.rscompress_for_provider()with per-tool summarizerstools/read.rssession/skills.rsproviders/traits.rsSendOptions.system_prompt:Option<String>→Vec<String>providers/anthropic.rsproviders/{openai,google,ollama}.rssession/{conversation,agent_loop}.rs,tui/conversation.rsTest plan
🤖 Generated with Claude Code