Skip to content

Fix Pi context meter window#62

Merged
glittercowboy merged 1 commit intomainfrom
codex/fix-pi-context-meter
Apr 28, 2026
Merged

Fix Pi context meter window#62
glittercowboy merged 1 commit intomainfrom
codex/fix-pi-context-meter

Conversation

@glittercowboy
Copy link
Copy Markdown
Contributor

@glittercowboy glittercowboy commented Apr 28, 2026

Summary

  • Pi control stats use the active Claude model to choose the context window when Pi returns token totals without a window.
  • Claude Opus 4.6 and Sonnet 4.6 register with a 1M context window in the daemon Pi extension.
  • Actor control requests carry the most recent Pi model so manual compaction refreshes use the same window as task execution.

Verification

  • go test ./internal/pi -run 'TestRunControl|TestContextWindow|TestAutoThreshold'
  • go test ./internal/session -run 'TestActorPiExecutorUsesPersistentSessionFile|TestNormalizePiModel|TestActorHandlesContextStatsRequest|TestActorHandlesCompactRequestLifecycle'
  • go test ./...
  • go build -o /tmp/gsd-cloud-context-meter .

Post-merge

  • Release a new daemon tag so installed daemons pick up the binary and packaged Pi extension metadata.

Summary by CodeRabbit

  • New Features

    • Expanded context window support for Claude Opus 4.6 and Sonnet 4.6 models, increasing capacity to 1,000,000 tokens
  • Improvements

    • Enhanced model-based context window configuration and usage tracking for more accurate context management

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a9b08664-6396-4932-87ed-25fb23f9b8c5

📥 Commits

Reviewing files that changed from the base of the PR and between cc80fdc and 15a144f.

📒 Files selected for processing (5)
  • internal/pi/control.go
  • internal/pi/control_test.go
  • internal/pi/extension/index.ts
  • internal/session/actor.go
  • internal/session/actor_test.go

📝 Walkthrough

Walkthrough

The pull request adds Model and ContextWindow fields to ControlOptions, implements ContextWindowForModel() to derive context windows based on model names, and updates the actor to dynamically track and propagate the current Pi model through control invocations. Context window configuration is also increased for Claude 4.6 variants.

Changes

Cohort / File(s) Summary
Control Path
internal/pi/control.go, internal/pi/control_test.go
Added Model and ContextWindow to ControlOptions. Implemented ContextWindowForModel() for model-based context window selection with parsing/normalization of Claude model variants. Updated readControlOutput and context usage synthesis to apply fallback context window consistently. Tests updated to verify model-based selection and larger token counts.
Actor State Management
internal/session/actor.go, internal/session/actor_test.go
Added setPiModel() and currentPiModel() methods to track the most recently used Pi model in actor state. Modified runPiControl to use dynamic model source via actor.currentPiModel(). Pi task execution persists normalized model before executor runs. Tests verify model propagation with normalization of bracket-suffixed model strings.
Extension Configuration
internal/pi/extension/index.ts
Increased contextWindow from 200_000 to 1_000_000 for both claude-opus-4-6 and claude-sonnet-4-6 model registrations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A model hops into the control pen,
Context windows stretch wide, then again!
The actor tracks models with careful delight,
From task to command, the path shines so bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Pi context meter window' is concise and clearly refers to the main change: updating how Pi determines the context window for stats calculation based on the active Claude model.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-pi-context-meter

Comment @coderabbitai help to get the list of available commands and usage tips.

@glittercowboy glittercowboy merged commit dc3f9ca into main Apr 28, 2026
1 of 2 checks passed
@glittercowboy glittercowboy deleted the codex/fix-pi-context-meter branch April 28, 2026 02:54
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.

1 participant