Skip to content

fix(status): correct context percentage and sync consolidator#3209

Merged
Re-bin merged 1 commit intomainfrom
worktree-fix-status-context-pct
Apr 16, 2026
Merged

fix(status): correct context percentage and sync consolidator#3209
Re-bin merged 1 commit intomainfrom
worktree-fix-status-context-pct

Conversation

@chengyongru
Copy link
Copy Markdown
Collaborator

@chengyongru chengyongru commented Apr 16, 2026

Summary

  • Fix /status context percentage exceeding 100% and inaccurate counting
  • Pass resolved self.context_window_tokens to Consolidator instead of raw parameter (could be None)
  • Calculate percentage against input budget (ctx - max_completion - 1024) instead of raw context window, consistent with Consolidator/snip budget formulas
  • Add "of input budget" label so the percentage is unambiguous

Changes

  • loop.py: Pass self.context_window_tokens (resolved) to Consolidator instead of raw parameter
  • helpers.py: Use input budget as percentage denominator (ctx_total - max_completion_tokens - 1024), cap at 999, add "of input budget" label
  • builtin.py: Pass actual max_completion_tokens from provider to build_status_content
  • test_build_status.py: Add 2 tests for budget-based percentage and 999 cap

Display

Before:

📚 Context: 30k/128k (23%)

After:

📚 Context: 30k/128k (25% of input budget)

The fraction uses the total context window; the percentage uses the input budget (total minus completion reserve and safety buffer), aligned with how Consolidator and _snip_history calculate budgets.

Test plan

  • tests/test_build_status.py — 6 passed (2 new)
  • Full suite — 1664 passed, pre-existing failures unrelated

@chengyongru chengyongru marked this pull request as draft April 16, 2026 06:41
@chengyongru chengyongru force-pushed the worktree-fix-status-context-pct branch from d39a1c3 to e106349 Compare April 16, 2026 06:54
…ator

- Pass resolved self.context_window_tokens to Consolidator instead of
  raw parameter that could be None, preventing consolidation failures
- Calculate percentage against input budget (ctx - max_completion - 1024)
  instead of raw context window, consistent with Consolidator/snip formulas
- Pass actual max_completion_tokens from provider to build_status_content
- Cap percentage display at 999 to prevent runaway values
- Add tests for budget-based percentage and cap behavior
@chengyongru chengyongru force-pushed the worktree-fix-status-context-pct branch from e106349 to f33cc38 Compare April 16, 2026 06:58
@chengyongru chengyongru marked this pull request as ready for review April 16, 2026 07:01
@chengyongru chengyongru added the enhancement New feature or request label Apr 16, 2026
@chengyongru
Copy link
Copy Markdown
Collaborator Author

#3131

Copy link
Copy Markdown
Collaborator

@Re-bin Re-bin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ;)

@Re-bin Re-bin merged commit e1fdca7 into main Apr 16, 2026
3 checks passed
@Re-bin Re-bin deleted the worktree-fix-status-context-pct branch April 16, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants