Skip to content

feat(cursor): expose native per-call context usage - #926

Merged
stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/cursor-context
Nov 18, 2026
Merged

stamp-build[bot] merged 1 commit into
mainfrom
agent/otter/cursor-context

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

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


Cursor SDK 1.4.1 reports each completed model call's full input count, including cache, but OAR previously kept context unknown. Project that native count into usage.context while preserving whole-turn spend and leaving the context window unknown. A successful native compaction clears the old reading until another model call supplies one.

Retained November 17 native evidence distinguishes the last call's 13,595 input tokens from the turn's 27,060 total; no new account calls were made. Offline controls validate the published SDK schema, multi-call spend, zero and invalid counts, child-update exclusion, and compaction invalidation. Full local check passed 4,847 unit tests and 19 mock behavior cases. The report documents the independent summary/delta stream ordering boundary.

Also records the agreed Qoder boundary: context stays unknown until task #277 retains usage frames from its already-approved cases, without extra model requests. No Qoder mapping changes.

@stamp-build
stamp-build Bot merged commit 27e9e97 into main Nov 18, 2026
22 checks passed
@stamp-build
stamp-build Bot deleted the agent/otter/cursor-context branch November 18, 2026 09:27
@stamp-build stamp-build Bot mentioned this pull request Nov 18, 2026
stamp-build Bot added a commit that referenced this pull request Nov 18, 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_b8936a7a3676f7ba6a8c17eabd41e91f"><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 -->

Cursor and Qwen sessions now report how full the current context is, through `usage.context` and `Session.contextUsage()`, from each runtime's own count.

## Cursor: current context from the last model call (#926), feature
Cursor SDK 1.4.1 reports each completed model call's full input count, cache included (`model-call-completed.usage.inputTokens`). OAR now projects that count into `usage.context.tokens`; each call replaces the previous reading rather than adding to it. The SDK reports no context window, so `contextWindow` and `percent` stay null. A completed native summary clears the reading until the next model call supplies one. Whole-turn spend is unchanged: in the retained native sample, the last call's input was 13,595 tokens while the turn spent 27,060.

## Qwen: current context after each turn (#927), feature
After each non-aborted root turn, OAR asks Qwen for its own `get_context_usage` and records the last prompt's token count and the context window before `turn_ended` and before any queued input is sent. Counts Qwen marks as estimated stay unknown, including the zero it reports before the first prompt. OAR never derives occupancy from cumulative input. If the query fails, times out (1 second) or the runtime lacks it, the turn still ends normally and the last known reading stays, so the value can lag one turn. Native controls on Qwen 0.28.0 and the CI-pinned 0.27.4 measured 2 to 15 ms per query and no extra provider requests.

Qoder's context stays unknown until retained native usage frames show what it reports.

## Also
- The shared stream-json driver gains optional readbacks that run after a root result and before the turn is settled; replies stay consumable, and exit, disposal or timeout cannot leave a turn unsettled (#927).
- Qwen: the context cost test isolates the readback from Qwen's own managed-memory extraction, which can start after `result` and overlap it (#930, test and docs only).

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

Co-authored-by: Cindy <[email protected]>
stamp-build Bot added a commit that referenced this pull request Nov 24, 2026
Record the November 24 daily runtime check, including the original attempts for all five failed jobs across four workflows. All three Antigravity 1.5.16 jobs passed, and all four updater manifests match the existing pin.

Compare the frozen candidates with the four versions that changed since the previous inventory. On Linux, Cursor SDK 1.5.0 passed login and configuration probes. The unmodified skills observer failed before comparison. Using the candidate bundle's context factory in a diagnostic copy restored parity for both fixtures. A three-platform 1.5.0 result is still pending.

Correct the daily Cursor replay assertion to check the per-call context event introduced in #926. Both the pinned SDK and 1.5.0 compiled against the host interface and passed the corrected replay.

Validation: `CI=1 pnpm run check` passed locally (5,650 unit tests and 19 mock behavior cases). All five failed job logs were read. The report totals and local links were checked against the retained artifacts.

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