Skip to content

feat(loop): propagate context usage from Claude backend#319

Open
williamjameshandley wants to merge 6 commits into
masterfrom
feat/loop-context-tracking
Open

feat(loop): propagate context usage from Claude backend#319
williamjameshandley wants to merge 6 commits into
masterfrom
feat/loop-context-tracking

Conversation

@williamjameshandley

Copy link
Copy Markdown
Contributor

Summary

  • Extract usage metadata (token counts, cost, turn count) from Claude Code's result event in the loop backend
  • Propagate through daemon → protocol → client → MCP tool
  • Messenger appends a context percentage warning when usage exceeds 80%, with "auto-compacted" note at 100%+
  • RunOutput(str) subclass provides backward-compatible metadata enrichment on client.run()

Test plan

  • Verify messenger shows [context: N%] warning when Claude context exceeds 80%
  • Verify non-Claude backends (Python, Bash) are unaffected (usage defaults to empty)
  • Verify client.run() still works as a plain string in existing consumers
  • Check RunResult MCP tool output includes usage fields when available

🤖 Generated with Claude Code

williamjameshandley and others added 3 commits February 19, 2026 22:05
Gemini 3.1 Pro released today with improved reasoning (77.1% ARC-AGI-2)
and precise tool usage. Adds both the standard and customtools variants,
updates default_model, and adds medium thinking_level support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

williamjameshandley and others added 2 commits March 2, 2026 09:08
Extract usage, cost, and turn count from Claude Code's result event and
propagate through daemon → protocol → client → MCP tool. The messenger
appends a context percentage warning when usage exceeds 80%.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@williamjameshandley williamjameshandley force-pushed the feat/loop-context-tracking branch from 7593415 to 2b9c5f0 Compare March 2, 2026 09:08
Resolve conflicts: take master's model definitions (shared.py),
keep branch's _CONTEXT_WINDOW and _get_context_footer in messenger.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants