feat: add live context token counter after each orchestrator loop#3351
Open
carTloyal123 wants to merge 1 commit into
Open
feat: add live context token counter after each orchestrator loop#3351carTloyal123 wants to merge 1 commit into
carTloyal123 wants to merge 1 commit into
Conversation
|
|
Display an inline debug-style context usage line after each LLM round-trip in the orchestrator loop. Shows current token count, approximate prefix, and compaction threshold so users can monitor context growth in real time during multi-tool-call turns. Also adds a unit test verifying Claude Opus 4.6 compaction threshold computes correctly as min(1M, 1M * 0.9) = 900k with the user's token_threshold and token_threshold_percentage config. Co-Authored-By: ForgeCode <noreply@forgecode.dev>
0bcc1ea to
6c6a755
Compare
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
Adds an inline debug-style context usage line after each LLM round-trip in the orchestrator loop, so users can monitor context growth in real time during multi-tool-call turns.
What it does
After each iteration of the orchestrator's
while !should_yieldloop (i.e., after the LLM response + tool results are folded into the context), aTitleFormat::debugmessage is emitted showing:~prefix)/ 900.0k)Example output:
Changes
crates/forge_app/src/orch.rs: Addedemit_context_usage()helper andhumanize()formatter. Emits context line after each loop iteration at the point where context is fully updated.crates/forge_domain/src/agent.rs: Added unit testtest_compaction_threshold_claude_opus_4_6_with_1m_context_windowverifying the compaction threshold calculation for 1M-context models.Testing
cargo test -p forge_domain test_compaction_threshold_claude_opus_4_6cargo checkpasses across workspaceCo-Authored-By: ForgeCode noreply@forgecode.dev