Skip to content

feat(account-usage): say what each usage window is tied to - #753

Merged
stamp-build[bot] merged 4 commits into
mainfrom
cindy/usage-window-scope
Nov 12, 2026
Merged

stamp-build[bot] merged 4 commits into
mainfrom
cindy/usage-window-scope

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Cindy from open-agent-runtime opened this pull request through Stamp
View in Stamp →


AccountUsageWindow.scope says what the runtime ties each usage window to, so a host can tell which windows hold back which model (Raft's Computers page and agent readiness, #oar-raft d0aeb454).

  • { kind: "account" }: the runtime reports the window as the account's.
  • { kind: "model", name }: one model's, with the runtime's own display name for it (Claude 2.1.322 get_usage: the keys seven_day_opus / seven_day_sonnet and the server's display name for each model_scoped row; Codex: limitName). OAR keeps that name as given: it can be a quota alias (Codex limitName can be gpt-reserve), OAR does not rewrite it from normalModelSlug, and it is not promised to equal a listModels id or display name; the host matches it to its own models.
  • Omitted, meaning unknown, where the runtime says neither: Claude's seven_day_oauth_apps, a Codex bucket that is neither the unnamed codex one nor named, a Kimi row with only a name.

Codex is not "all models": its unnamed codex bucket is account, a named bucket such as "GPT-5.3-Codex-Spark" is model, and Codex does not say whether the account bucket also binds that model. The spec says which windows concern a model (every account window plus the model windows naming it), that scope says what a window counts and not whether a full one stops work (extra usage; rateLimited weighs it), and gives a per-runtime table.

Additive optional field; existing fields unchanged.

🤖 Generated with Claude Code

Cindy and others added 2 commits November 12, 2026 07:58
AccountUsageWindow.scope: account, or one model by the runtime's own name
(claude Opus, Sonnet and model_scoped rows; codex named buckets). Omitted
where the runtime says neither. Asked by Raft for its Computers page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stamp-build
stamp-build Bot force-pushed the cindy/usage-window-scope branch from 479e319 to d87fd95 Compare November 12, 2026 13:02
@stamp-build

stamp-build Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

GO at 75bf09232dd1181bd8e90b39223661d3f2da45c1, base 0906cce017f0cab7f9996b6a39a29c615b708fd1.

The projections preserve the runtime's distinctions: Claude's OAuth-app window, unnamed non-default Codex buckets, and name-only Kimi rows stay unscoped. Named model windows retain their native names. Existing usage, reset and exhaustion calculations are unchanged.

The review corrections are now reflected in the spec and contract:

  • Scope describes accounting coverage, not a decision to stop work. Extra usage can remain available after a subscription window fills.
  • Missing scope means unknown. Treating it as account-wide is explicitly a host policy, not a native fact.
  • A native name may be a quota alias. Codex's limitName: "gpt-reserve" projects to scope: { kind: "model", name: "gpt-reserve" }; normalModelSlug does not replace it, and equality with a listModels ID or display name is not guaranteed.

Validation: 122 targeted tests across the four account readers and query deadlines passed, as did the repository typecheck. Those ran on the original feature commit; range-diff confirms the rebase preserved that patch and subsequent changes only revise documentation and a contract comment. The final diff passes git diff --check. Independently replayed the native Codex Reserve bucket shape, and generated the Codex 0.167.1 app-server types offline to verify the related-field distinction. Native source inspection also supports the Grok and Kimi account-window projections.

No real account query, login, reset or model call was made. Cross-platform CI remains pending; author owns merge after it passes.


Otter commented through Stamp · server open-agent-runtime · reviewed head 75bf092
View in Stamp →

@stamp-build
stamp-build Bot merged commit f571d97 into main Nov 12, 2026
40 checks passed
@stamp-build
stamp-build Bot deleted the cindy/usage-window-scope branch November 12, 2026 14:02
@stamp-build stamp-build Bot mentioned this pull request Nov 12, 2026
stamp-build Bot added a commit that referenced this pull request Nov 12, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_ab238713ca1834e477cdf55ade43ffdb"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup>

---
<!-- /stamp:review:v1 -->

Claude limit resets through Claude Code's own interactive UI, and usage windows that say which model they count.

## Claude: limit resets (#752)
- New optional member `Runtime.inspectLimitResets(installation, options?)` (Claude only) lists the account's resets per kind: `weekly`, `fable`, `full`, and `five_hour` only with `includeFiveHour: true`. Each kind is `available` (with `resetsLeft` and `expiresText`), `none`, `not_offered`, `unknown` or `not_checked`; the result also carries the Claude Code `version`, and `program: "legacy"` / `fiveHourSpent: true` when the older program answered.
- `claudeRuntime` now has `redeemLimitReset(installation, { idempotencyKey, resetId })`; for Claude `resetId` is required and names the kind. Claude's `accountUsage` still reports no `limitResets`: list them with `inspectLimitResets`, not from the usage snapshot.
- Claude Code 2.1.322 has no `-p`, SDK or control-protocol form, so OAR drives the hidden `/limit-reset <kind>` command in a pseudo-terminal (the system `script`) and reads the screen. Every screen must match the recorded text word for word apart from dates, counts and percentages (the whole confirmation dialog included); anything else ends the attempt with Esc. Yes is sent at most once, never while inspecting.
- At the 5-hour limit, Claude's older reset program spends its reset as soon as any `/limit-reset` opens. Without `fiveHourLimitConsent: true`, OAR reads usage right before the first command and types nothing when the account is at the limit (`consent_required`) or the read fails (`not_attempted` / `usage_unread`). A `weekly`, `fable` or `full` redeem without consent also needs Claude Code's cached feature flags to show the newer reset program, and otherwise answers `consent_required`. A `five_hour` redeem is itself the consent.
- An idempotency key is remembered for the life of the process once its attempt typed a command: the same key gets the first answer, never a second Yes; the same key with another `resetId` rejects. An attempt that sent nothing is not remembered. Claude answers a timeout with `not_attempted` or `unknown` instead of rejecting (Codex still rejects).
- Each call starts Claude Code's UI, which sends one 1-token model request at startup; on a subscription it likely counts as usage. `inspectLimitResets` is not a passive read: call it on the account owner's request and never poll it.
- Linux only, with the system `script` (util-linux) available; anywhere else, or without it, the answer is `unsupported_platform`. (macOS's BSD `script` exits when its stdin is a socket, which Node pipes are there.)
- Evidence: the screen recognisers come from Raft's offline harness, which drove the real 2.1.322 UI against a fake backend; the real server's Fable and full screens are unverified, and no real account's reset has been spent through OAR.

**Source compatibility.** New exported types: `LimitResetInspection`, `LimitResetInspectOptions`, `LimitResetInspector`, `LimitResetKindStatus`, `LimitResetNotAttemptedReason`, `LimitResetUnsupportedReason`, `AccountUsageWindowScope`; new option `LimitResetOptions.fiveHourLimitConsent`. `LimitResetResult` gains `not_attempted` (`busy`, `deadline`, `usage_unread`, `startup_failed`) and `unknown` (optionally `fiveHourSpent`), and its `unsupported` reason is now typed `LimitResetUnsupportedReason` (the account-usage reasons plus `unsupported_platform`, `unsupported_version`, `reset_id_required`, `consent_required`). Codex's behavior is unchanged, but a host with an exhaustive `switch` over these unions, or one that assigns the reason to `AccountUsageUnsupportedReason`, needs updating. A host that offered redeem only where `redeemLimitReset` exists now sees it on Claude too. `oar list` gains an `inspectLimitResets` key.

## Account usage: window scope (#753)
- `AccountUsageWindow.scope`: `{ kind: "account" }` when the runtime reports the window as the account's, `{ kind: "model", name }` when it reports it as one model's, with the runtime's own name kept as given (Claude "Opus", "Sonnet", "Fable"; Codex `limitName`, which can be a quota alias such as `gpt-reserve`). Omitted, meaning unknown, where the runtime says neither (Claude's OAuth apps window, Codex's other unnamed buckets, Kimi's name-only rows).
- `scope` says what a window counts, not whether a full one stops work: extra usage can carry Claude, Grok and Kimi accounts past a full subscription window, which `rateLimited` already weighs.

Also in this release: spawn validation errors no longer echo a rejected argument or environment value (#751).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Cindy <[email protected]>
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.

0 participants