gut(session): remove vestigial contextTokens config and display denominator#2277
Merged
alexey-pelykh merged 2 commits intomainfrom Apr 11, 2026
Merged
gut(session): remove vestigial contextTokens config and display denominator#2277alexey-pelykh merged 2 commits intomainfrom
alexey-pelykh merged 2 commits intomainfrom
Conversation
…inator (#2133) Remove the `contextTokens` field, `DEFAULT_CONTEXT_TOKENS` constant, `lookupContextTokens` stub, and all derived fields (`remainingTokens`, `percentUsed`) across the entire codebase — types, schemas, agent runner, session persistence, directive handling, status display, gateway, TUI, UI, native apps (macOS/shared kit), agent tools, cron, and documentation. The contextTokens denominator was a static config value (defaulting to 200k) used to display misleading context window utilization percentages. The lookup stubs were gutted, making the resolution chain fall through to hardcoded values regardless of actual runtime context window size. Token display is simplified from "45k/200k (22%)" to "45k used". Real token counting infrastructure (totalTokens, inputTokens, outputTokens, cacheRead, cacheWrite) is preserved — only the static denominator and percentage display are removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92ff7a8 to
ccf4849
Compare
…from rebase Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
alexey-pelykh
added a commit
that referenced
this pull request
Apr 17, 2026
Ports 13 @test functions from upstream commit 061b825 ("macOS: add chat model selector and persist thinking") that were skipped during the fork sync in #2379. Issue #2381 states "9 tests" but the actual v2026.3.8..v2026.3.11 cycle delta is 13 — verified via git log. Ten model-selection tests cover: bootstrap, default patch, provider- qualified disambiguation, provider-qualified slash IDs, stale patch race, send-waits-for-patch, failed-latest replay, failed-latest restore, session-switch late patch, cross-session replay isolation. Three thinking-level tests cover: explicit level persistence, server- provided levels outside menu, stale patch replay. Decision on contextTokens: adapt tests to omit. Fork gutted the field in #2277 — extending types would revert that deliberate decision. Helper infrastructure ported: 14 private helpers (functions, actors, classes). TestChatTransport extended with modelResponses + optional hook params (backward-compatible) and new async query methods. Existing 11 tests preserved verbatim. Local compile blocked by pre-existing symbol references in RemoteClawKit/GatewayChannel.swift (see #2388). Fork CI has no Swift jobs so this state also pre-exists and is orthogonal to this change. Closes #2381. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 17, 2026
This was referenced Apr 26, 2026
alexey-pelykh
added a commit
that referenced
this pull request
Apr 26, 2026
…2583) (#2596) Process Cat A cluster A2 of the v2026.3.22 upstream sync backlog: 35 fork files under apps/macos/ requiring per-file disposition. Disposition outcome: | Action | Count | |--------|------:| | CHERRY-PICK applied (rebrand transform → fork content changes) | 27 | | EXCLUDE-DIVERGENT (registered in hq/upstream/disposition.tsv) | 4 | | Total | 31 issue-listed | | Helper files imported (net-new upstream additions referenced by cluster cherry-picks) | 15 | | PairingAlertSupport refresh (refactored upstream — fork's older version replaced) | 1 | Issue body listed 31 CHERRY-PICK + 4 EXCLUDE-DIVERGENT = 35. After per-file inspection, all 4 of the 4 EXCLUDE-DIVERGENT entries were pre-classified by triage and were not reclassified (rate: 0% reclassification — within the 5-10% the issue body anticipated). The 27/31 CHERRY-PICK count reflects upstream content that genuinely diverges; the remaining 4 of 31 were NOOP (fork already in sync after rebrand transform). EXCLUDE-DIVERGENT classifications (all 4): - apps/macos/Sources/OpenClaw/ContextUsageBar.swift - apps/macos/Sources/OpenClaw/SessionMenuLabelView.swift - apps/macos/Sources/OpenClaw/SessionsSettings.swift - apps/macos/Sources/OpenClaw/UsageMenuLabelView.swift All four trace to fork commit f7e9156 — gut(session): remove vestigial contextTokens config and display denominator (#2277). Upstream still references the gutted contextTokens symbols. Approach: 1. Read upstream@v2026.3.22 content via `git show v2026.3.22:{path}`. 2. Apply token-based rebrand transforms per hq/upstream/rebrand-tokens.tsv — `OpenClaw → RemoteClaw`, `openclaw → remoteclaw`, `OPENCLAW → REMOTECLAW`, `OPENCLAW_ → REMOTECLAW_`, `ai.openclaw → org.remoteclaw`, `com.openclaw → org.remoteclaw`, `~/.openclaw → ~/.remoteclaw`, `.openclaw → .remoteclaw`, `openclaw-mac → remoteclaw-mac`, `@openclaw/ → @remoteclaw/`, `github.com/openclaw/openclaw → github.com/remoteclaw/remoteclaw`, `openclaw/openclaw → remoteclaw/remoteclaw`, `openclaw.io|openclaw.ai → remoteclaw.com`. 3. Cross-class API audit detected upstream extracted helper logic into 13 net-new Swift files (PlatformLabelFormatter, SettingsRefreshButton, GatewayPushSubscription, JSONObjectExtractionSupport, TextSummarySupport, SimpleTaskSupport, TrackingAreaSupport, MicRefreshSupport, AgentWorkspaceConfig, SystemSettingsURLSupport, PermissionMonitoringSupport, VoiceOverlayTextFormatting, VoiceWakeRecognitionDebugSupport) plus 1 in RemoteClawMacCLI (CLIArgParsingSupport) and 1 in shared kit (CaptureRateLimits). All 15 imported with rebrand transforms applied — they're net-new upstream additions referenced by cluster cherry-picks (not in audit's rebrand-below-threshold cluster lists because audit only flagged renames, not additions). 4. PairingAlertSupport.swift was refactored upstream — fork's older 46-line version is replaced with upstream's 277-line refactor (with rebrand transforms applied) so cherry-picked NodePairingApprovalPrompter compiles. Fork's prior content (PairingAlertHostWindow, endActiveAlert, requireAlertHostWindow) is preserved verbatim by upstream's superset. Notes: - PeekabooBridgeHostCoordinator cherry-pick adds compatibility code that creates symlinks for upstream's pre-rebrand brand directory names (clawdbot, clawdis, moltbot). For fresh fork users these are no-op ghost directories. Polish reviewer agreed this is acceptable as literal upstream-parity (fork users have no pre-rebrand state per CLAUDE.md "User state boundary"). Optional follow-up: gate symlink creation behind fileExists check. - Fork CI does not build macOS (per CLAUDE.md). Local Xcode build and swift test NOT verified — same caveat as merged Wave 1 PR #2595. Closes #2583. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
contextTokensfield fromSessionEntry,AgentDefaultsConfig, Zod schema, and all downstream types (status, gateway, TUI, UI, native apps)DEFAULT_CONTEXT_TOKENSconstant,lookupContextTokensstub,resolveContextTokensstub, and thecontextTokensUsedresolution chain in agent-runnerremainingTokensandpercentUsedfromSessionStatusand all consumers"45k/200k (22%)"to"45k used"across status output, sessions list, TUI, macOS app, and shared kitRationale
The
contextTokensdenominator defaulted to 200k regardless of actual runtime context window (Gemini has 1M, some Claude models have 1M). The lookup stubs were gutted in the RemoteClaw fork, making the resolution chain always fall through to hardcoded values. Removing the misleading percentage is better than displaying an inaccurate one.Real token counting infrastructure (
totalTokens,inputTokens,outputTokens,cacheRead,cacheWrite) is fully preserved.Closes #2133
Test plan
pnpm checkpasses (format, typecheck, lint)server.roles-allowlist-update.test.ts)grep -r contextTokens src/ ui/ apps/ docs/returns no matchesgrep -r DEFAULT_CONTEXT_TOKENSreturns no matches🤖 Generated with Claude Code