You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Usage budget view: Claude and Codex meters, credits, and top usage by task and wake reason #508
Part of #506 (plan: #506 (comment), 'Budget and decisions'). Owner decision 2026-11-19.
Problem
The owner can't budget usage: Codex per-turn token use is stored (orchestration_v2_projection_provider_turns.payload_json.turnTokenUsage) but never shown, and Claude usage is only visible by parsing session logs.
Wanted
Record per provider turn: model, role, effort, project/issue, thread, parent, start trigger (user, child result, background completion, nudge, fix round, re-check), request count, first and peak context, uncached input, cache reads, cache writes, output. Count each streamed response once; don't double count a child in its parent.
Show weekly and short-window meter headroom, reset time, pace and credit balance next to the top tasks, stages and wake reasons. Mark stale or partial data. The provider meter is the quota authority; credit estimates are shown separately.
The weekly usage report (scheduled task in the global-rules project) becomes a plain query of this data; a model is called only when the owner asks for interpretation. Update or replace that scheduled task when this ships.
Done when
The owner can see, in the app, what used Claude and Codex this week and why, without a model run.
Add a Budget view to the existing Usage page. Pair the provider's current meters and credit balances with a seven-day breakdown of recorded T3 work. The same read should power the weekly report.
Most attribution keys exist. The turn points to an attempt or node, the run has the initiating message and model selection, and the thread has role, project, issue links, and parent lineage. Messages already carry notification, delegated completion, and scheduled task metadata. Historical stage and exact wake classification are incomplete. Request count and first/peak request context are absent from the persisted turn usage shape. Turn, attempt, node and thread row keys · Thread attribution · Run selection and initiating message · Message metadata · Turn usage contract
Use the latest persisted turnTokenUsage once per provider-turn ID. Start from turns and use keyed joins through the attempt or the owning node/provider thread for native children, then to the run, initiating message and app thread. Use the execution-time model when known, the run's recorded selection for effort/speed where available, and the parent environment/thread reference for remote delegation. For task grouping prefer the managed issue's full identity, then a single explicit issue link or scheduled task ID, then the app thread. Keep ambiguous links in the thread bucket. A parent wake belongs to its own task/run. Its child references can explain the wake without splitting or copying its tokens.
Keep the existing projection tables. Add optional fields only where joins cannot recover facts. On new starts capture the selected issue/project on the existing run where mutable links or project moves could change attribution. Record an explicit stage on that run when the workflow knows it. Reuse the initiating message's structured cause when it is sufficient, with an optional run-start reason for details that otherwise disappear. A continuation or restart gets its own reason only when it starts a new turn. Use honest fallback labels for legacy rows, and let stable thread IDs survive missing display labels. Avoid a history rewrite.
Extend the existing adapter accumulators and optional turnTokenUsage fields for request count and first/peak input context. Claude already replaces streamed snapshots by assistant message ID. Count acknowledged model responses by that identity, retaining distinct steered segments. For Codex use a verified response boundary if available, with cumulative deltas for tokens and the per-response last value for context. Repeated snapshots and a delta spanning several responses cannot establish a request count. Leave unsupported metrics unknown and preserve genuine zeroes. Use observed input including cache for context, and keep compaction/coverage flags where the provider exposes them. Claude per-message accumulator · Codex cumulative delta
Sum the normalized input and output totals once. Cache reads/writes are input subsets and reasoning is an output subset. Derive uncached input only when the needed components are known under that provider's semantics. Exclude local-command records from model usage. Count independently metered child turns under their own identity. Keep the Claude process-ledger residual (otherUsage, which can include native children and compaction) outside ranked and additive totals. Show residual/coverage separately when visible, with an overlap caveat. Treat legacy, interrupted, or provider-scope-ambiguous measurements as partial. The existing telemetry already models root, native-child, and residual usage separately. Claude ledger residual · Root and child accounting
Expose one server read for the bounded weekly summary with the existing usage diagnostics access guard. Use an indexed half-open range on provider-turn completion time for settled turns, including retained failed/interrupted/cancelled turns with usage. Use indexed point joins and a capped top list per provider and grouping, with bucket totals and coverage counts. The current turn indexes do not support a global time range, so add one narrow completion-time index if no equivalent lands first. Keep completed-turn scans on the existing SQLite reader worker, with a short read transaction and request coalescing for identical concurrent reads. Fetch only on Budget entry, scope change, manual refresh or scheduled report execution. Keep live turns, shell snapshots, provider events, meter updates and role admission free of weekly work. Verify the query plan against representative isolated data. Provider-turn table and original indexes · SQLite reader worker · Usage diagnostics access
View and weekly report
In Usage → Budget, put the existing Claude and Codex account/model-window cards above the ranked tables. Show short and weekly headroom, reset time, pace, freshness, and provider-reported credits, preserving distinct reset-credit and purchased-credit labels. Each ranking switches between Role, Task, Stage, and Wake reason. Rows show recorded tokens with the input/cache/output split, counts and known context statistics on drill-in, and links when an issue/thread is accessible. Show the exact dates, as-of time, scope, and unknown/partial coverage. Meter windows and the seven-day activity window get their own dates. Keep token ranks independent of the provider meter. If reliable model/speed pricing is available, label any Codex credit estimate separately and leave unresolved rates unknown. Keep quota percentages and actual balances sourced from the provider.
Give Scheduled Tasks one typed Usage budget report action. It calls the same summary read and current meter snapshot, formats the date range, top rows and coverage deterministically, and keeps the latest report with the existing task's status. Use the scheduled occurrence as the publication key so a retry updates that report. Report errors and last successful timestamp separately. Preserve the enabled Sunday schedule when converting the owner's named task after verification. Keep the report's usage scope environment-wide, as in the old task, even though the schedule belongs to global-rules. A requested interpretation can read the report in a separate user-initiated turn.
Delete at cutover: retire the old prompt, its Investigator delegation and its ad hoc JSONL summation, title matching and guessed stage classification. Keep the existing Usage history reader for its broader coverage, and let Consolidate usage readers and role policy onto upstream contracts #420 own removal of duplicate usage readers and role-policy plumbing.
Dependencies and single-implementor tasks
Weekly server read and accounting. Build now against projections and the existing usage contract. Include coverage, keyed attribution from existing fields, query-plan evidence, and focused fixtures for reruns, duplicate snapshots, partial data and child/residual overlap. Keep the history and meter reader behind its existing service boundary so Consolidate usage readers and role policy onto upstream contracts #420 can consolidate its implementation.
Capture missing turn and run facts. Build request/context observations and explicit stage/task metadata now. Use existing structured message causes provisionally. After Batch routine child results into one orchestrator wake #507, wire its delivery classification at actual run start, including one parent wake for the 15-second routine batch and immediate delivery reasons for questions, blockers, actionable failure and an unblocking result. Store the batch size separately from the wake count. Implementors run their own review; the orchestrator wakes only to merge or decide #513 then verifies that merge/decision wakes stay visible, review/fix/re-check work stays with the implementor or separately measured native reviewer, and an in-place retry adds only the work it actually executes. Provider-internal nudges get a start reason only if a typed signal identifies a new turn. Avoid inferring them from prompt text. #507 · #513
Budget UI. Build once the server contract is available, using fixtures for missing facts and batched wakes. Reuse the current meter UI and align its data access with Consolidate usage readers and role policy onto upstream contracts #420 before release. Verify the web and Electron entry point, including the selected remote environment, with the existing usage permission and partial/missing states. #420
Scheduled action and cutover. Build the deterministic action once task 1 is available. Compare it with Budget for the same as-of time, then convert the live schedule after the attributed report is usable. Keep the production schedule change distinct from tests.
Owner decisions
Reporting window. Recommend a rolling seven-day settled-turn window for the view and weekly report. Show the provider's own reset windows beside it.
Stage labels. Recommend only explicit workflow/launch stage values, with Unspecified for older or unstaged work. Keep role and wake reason independently available.
Report destination. Recommend the latest dated report in the existing scheduled task's details, with the live Budget view available on demand. Keep historical model-written reports where they are.
Done when
The owner can open Usage → Budget and see both providers' current meter/credit status and the top recorded work by role, task, stage and wake reason, with dates, links and visible coverage gaps.
Replayed frames and overlapping snapshots preserve totals. Root and independently measured child usage reconcile without adding the provider residual. The test also covers repeated responses, missing fields, time-window edges, a mixed batch, and Implementors run their own review; the orchestrator wakes only to merge or decide #513's in-place retry and final-result wake.
The indexed weekly query runs through the read path only. A live turn and normal meter refresh issue no weekly aggregate query. Verify in an isolated environment with fixtures or Replay.
The converted schedule produces the same report as the view for the same scope and timestamp. A scheduled fire and its retry launch zero provider turns, create zero child tasks and publish one result.
Implemented Usage → Budget and the model-free weekly report in local commit a32ede1431. Issue #508
Budget shows Claude and Codex quota headroom, reset times, pace, and provider-reported credits alongside seven-day rankings by task, role, stage, and wake reason. The rankings flag partial coverage and show token and context details where available. Codex request counts and stages without a recorded workflow signal remain unknown.
Scheduled Tasks can save the same environment-wide summary as a Usage budget report. An isolated test converted the Sunday schedule in place and verified that repeated scheduler checks saved one report and launched zero agent turns.
The changed-file suite passed 1,025 tests, including browser coverage. Formatting, lint, dependency checks, and translation checks passed. The aggregate typecheck still reports seven issue-status errors that I reproduced on unchanged main.
The worktree is clean. Publishing, verification in the installed desktop app, and conversion of the live Sunday schedule remain pending.
Usage → Budget shows Claude and Codex quota meters, credit balances, and seven-day rankings by task, role, stage, and wake reason.
The weekly report saves the same summary without launching an agent. The live Sunday schedule conversion remains pending until deployment.
vp run check:changed passed 1,172 tests and reported only the seven agreed baseline web TS2345 errors. Independent review found no blockers.
PR #596 closes #508 on merge. Head cc86451c06280188d9a944e8bbbdd6fe6a750eec is open for review with no merge conflicts. GitHub shows no hosted checks for this head.
Activity
tannerpolley commentedon Nov 20, 2026
#508 design
Add a Budget view to the existing Usage page. Pair the provider's current meters and credit balances with a seven-day breakdown of recorded T3 work. The same read should power the weekly report.
Findings on
mainglobal-rulesis enabled for Sunday at 18:00 server-local time. It delegates a Claude log scan based on per-message usage and tells the investigator that Codex token counts are unavailable. The existing scheduled action sends a prompt to a thread or launches one. #506 plan and double-count correction · ScheduledTaskService.ts:1047–1076 · New-thread schedule pathData and query
turnTokenUsageonce per provider-turn ID. Start from turns and use keyed joins through the attempt or the owning node/provider thread for native children, then to the run, initiating message and app thread. Use the execution-time model when known, the run's recorded selection for effort/speed where available, and the parent environment/thread reference for remote delegation. For task grouping prefer the managed issue's full identity, then a single explicit issue link or scheduled task ID, then the app thread. Keep ambiguous links in the thread bucket. A parent wake belongs to its own task/run. Its child references can explain the wake without splitting or copying its tokens.turnTokenUsagefields for request count and first/peak input context. Claude already replaces streamed snapshots by assistant message ID. Count acknowledged model responses by that identity, retaining distinct steered segments. For Codex use a verified response boundary if available, with cumulative deltas for tokens and the per-responselastvalue for context. Repeated snapshots and a delta spanning several responses cannot establish a request count. Leave unsupported metrics unknown and preserve genuine zeroes. Use observed input including cache for context, and keep compaction/coverage flags where the provider exposes them. Claude per-message accumulator · Codex cumulative deltaotherUsage, which can include native children and compaction) outside ranked and additive totals. Show residual/coverage separately when visible, with an overlap caveat. Treat legacy, interrupted, or provider-scope-ambiguous measurements as partial. The existing telemetry already models root, native-child, and residual usage separately. Claude ledger residual · Root and child accountingView and weekly report
global-rules. A requested interpretation can read the report in a separate user-initiated turn.Dependencies and single-implementor tasks
Owner decisions
Done when
tannerpolley commentedon Nov 23, 2026
T3 Code status: Unavailable
Issue: #508 Usage budget view: Claude and Codex meters, credits, and top usage by task and wake reason
Thread: thread:delegated-task:milestone-issue%3Athread%3Adelegated-task%3Arepository-handoff%253A421f7a75-1bf7-49e2-abb0-448fcf274ea0%3A8%3A6502757298%3Afirst
Model: gpt-6.2-sol
Branch: issue-508-usage-budget-view-claude-and-codex
Updated: 2026-11-23T21:54:56.263Z
tannerpolley commentedon Nov 23, 2026
T3 Code closeout: done
Issue: #508 Usage budget view: Claude and Codex meters, credits, and top usage by task and wake reason
Thread: thread:delegated-task:milestone-issue%3Athread%3Adelegated-task%3Arepository-handoff%253A421f7a75-1bf7-49e2-abb0-448fcf274ea0%3A8%3A6502757298%3Afirst
Model: gpt-6.2-sol
Branch: issue-508-usage-budget-view-claude-and-codex
Completed: 2026-11-23T18:28:36.875Z
Implemented Usage → Budget and the model-free weekly report in local commit
a32ede1431. Issue #508The changed-file suite passed 1,025 tests, including browser coverage. Formatting, lint, dependency checks, and translation checks passed. The aggregate typecheck still reports seven issue-status errors that I reproduced on unchanged
main.The worktree is clean. Publishing, verification in the installed desktop app, and conversion of the live Sunday schedule remain pending.
tannerpolley commentedon Nov 23, 2026
T3 Code closeout: done
Issue: #508 Usage budget view: Claude and Codex meters, credits, and top usage by task and wake reason
Thread: thread:delegated-task:milestone-issue%3Athread%3Adelegated-task%3Arepository-handoff%253A421f7a75-1bf7-49e2-abb0-448fcf274ea0%3A8%3A6502757298%3Afirst
Model: gpt-6.2-sol
Branch: issue-508-usage-budget-view-claude-and-codex
Completed: 2026-11-23T21:52:15.620Z
vp run check:changedpassed 1,172 tests and reported only the seven agreed baseline web TS2345 errors. Independent review found no blockers.PR #596 closes #508 on merge. Head
cc86451c06280188d9a944e8bbbdd6fe6a750eecis open for review with no merge conflicts. GitHub shows no hosted checks for this head.