Repository navigation
fix(kimi): coordinate first Web token creation - #912
Merged
Merged
Conversation
stamp-build
Bot
force-pushed
the
agent/otter/kimi-web-startup
branch
from
November 17, 2026 23:43
f3b6f7d to
5d91615
Compare
stamp-build Bot
added a commit
that referenced
this pull request
Nov 18, 2026
<!-- stamp:review:v1 --> <sup><img src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp" width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_86c78e0782f4b9fc304272dc984a5be2"><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 --> A short skills query can stop Kimi after its background model-directory refresh rotates a refresh token on the server but before the replacement reaches disk. The next usage query then sends the old token and native Kimi can clear both credentials. Disable the native startup and periodic catalog-refresh switches only in the two read-only Web children's environments. Explicit /oauth/usage refresh remains enabled; caller environment and user configuration are unchanged. The committed generation-aware synthetic fixture and reproduction cover six paths, three rounds each. The former skills lifecycle loses the replacement in 3/3 cases; the actual fixed adapter passes sequential and concurrent reads with one explicit refresh. Raft's lock-disabled usage avoids further writes but cannot recover a token lost by earlier skill discovery. No real-account request was made; interrupted explicit refresh and graceful shutdown remain separate follow-up work. Validation: full local check passed 4,816 unit tests and 19 mock cases, Kimi 2.4.1 native login/skills/usage checks passed 16 cases, current 2.6.3 usage checks passed 7, and 16 native behavior cases passed. The new unit regression was observed failing before the fix. Native regression requires skills to make zero provider requests despite explicitly enabled caller flags, then verifies refresh and unchanged config bytes. Rebased onto main after #912 merged; the incremental patch is byte-identical to the approved change. Co-authored-by: Otter <[email protected]>
Merged
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_b57e0369afaab9df8988de1fe7f73eba"><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 --> Kimi's read-only queries no longer risk clearing the user's Kimi login, concurrent first Kimi Web starts and concurrent OpenCode starts no longer fail each other, and the Cursor SDK peer moves to 1.4.1. ## Kimi: read-only queries could clear the user's login (#913), fix With an expired Kimi access token, the short-lived `kimi web` process OAR starts for `skills()` (and `accountUsage()` on Linux/macOS) ran Kimi's default background model-catalog refresh. That refresh could rotate the OAuth refresh token on the server, and OAR then stopped the process before Kimi saved the replacement. A later refresh, such as the next usage read (by Kimi's source, also a session or the user's own `kimi`), sent the old token, was rejected, and Kimi wrote its revoked state: access and refresh tokens both empty, so the user had to log in again. One skills read was enough; no concurrency was needed. - Both read-only Web processes now start with `KIMI_CODE_MODEL_CATALOG_REFRESH_ON_START=0` and `KIMI_CODE_MODEL_CATALOG_REFRESH_INTERVAL_MS=0` in that child's environment only. The caller's environment and the user's Kimi configuration are unchanged. A usage read that needs a fresh token still refreshes once through `/oauth/usage` under Kimi's own lock. - Measured with Kimi 2.6.3 against a local OAuth server that rotates refresh tokens: before, 3/3 sequential skills-then-usage reads lost the login; after, 3/3 sequential and 3/3 concurrent reads kept it, with one explicit refresh. No real account was used. - Not covered: a usage refresh interrupted by a deadline, crash or termination can still lose its replacement (graceful native shutdown is separate follow-up work); Kimi session processes and Kimi processes started outside OAR are unchanged. - Hosts that set `KIMI_DISABLE_OAUTH_LOCK=1` for usage reads: that avoids usage-side writes, but it could not undo a token already lost by an earlier skills read. Upgrading fixes the skills side. ## Kimi: concurrent first Web starts (#912), fix This covers the read-only Web processes behind `skills()` and `accountUsage()`; Kimi ACP sessions are not gated. Two Kimi Web processes starting against one Kimi home with no `server.token` yet could each create a token, and the first process then rejected its own printed Web bearer token with HTTP 401. OAR now lets only one such start proceed per resolved Kimi home within one OAR process, until it is ready, exits or fails; the others wait within the caller's original deadline (in six ordinary cold pairs on Kimi 2.6.3, the second start began a median 1.9 s after the first), cancellation still works, and failed starts are not retried. A home that already has a non-empty token is not gated. Controlled Kimi 2.4.1 and 2.6.3 races: 3/6 requests failed before, 0/6 after. Several OAR processes sharing one Kimi home are not coordinated. ## OpenCode: concurrent starts sharing a data directory (#905), fix OpenCode could exit with `database is locked` when two processes started at once on one data directory: one was recovering the SQLite WAL while the other ran its first WAL statement before setting a busy timeout. OAR now serializes OpenCode ACP startup per data directory, from spawn until `initialize` answers; sessions still run concurrently. In a 12-open reproduction on an unchanged OpenCode: 5/12 failed before, 0/12 after; a waiting start took a median 1.66 s longer, inside the existing 60 s initialize deadline. Several OAR processes sharing one data directory are not coordinated. ## Cursor: SDK peer 1.4.1 (#911), dependency change The exact optional peer `@cursor/sdk` moves from 1.4.0 to 1.4.1. Hosts that use Cursor through OAR install `@cursor/[email protected]`; the `oar` CLI depends on it and installs it. On Linux with a real login and `gpt-5.4-nano`, all 12 applicable live scenarios and the 3 tool-denial rounds passed once each; offline login (11), configuration (6) and skills (2) checks passed. ## Also - Kimi docs: a resumed session (since Kimi 2.5.0, reconfirmed on 2.6.2 and 2.6.3) still advertises the MCP tools from its first open to the model, while execution follows the servers passed on resume. The workspace test now picks its expectation from the installed Kimi version (2.6.2 and later register a fresh ID) (#909). - Tests and CI: Cursor skill observer locates its loader by content (#906), daily candidate checkout keeps the Cursor version constant in step (#908), failed native skills/usage tests keep their evidence (#910), daily version report, including that Qoder 1.1.82 through 1.1.91 cannot replay offline, so CI replay stays on 1.1.81 (#907). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]>
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.
Two first Kimi Web processes can replace each other's server.token, making the first process reject its printed bearer with HTTP 401. Gate startup within one OAR host per resolved Kimi home, shared by account usage and skills, only while the native token is absent or whitespace-only. Release at readiness, exit or failure; queueing uses the caller's original deadline, cancellation preserves ownership, and failures are never retried.
Native 2.4.1 and 2.6.3 have identical inspected creation/cache functions. The committed timing-controlled reproduction fails 3/6 requests without coordination and 0/6 through the actual gate on 2.6.3. Ordinary cold pairs all pass with a median 1.877-second process-start separation; preseeded pairs pass with 4.5 ms separation. The report documents synthetic controls, cross-process limits, token-state acceptance, and the upstream removal condition. The historical macOS failure's precise cause remains unknown.
Validation: full local check after rebasing current main passed (4,815 unit tests and 19 mock cases); pinned Kimi 2.4.1 native login/skills/usage checks passed (15), as did 16 applicable native behavior cases. All 24 current-version experiment pairs completed. OAuth background-refresh shutdown is tracked separately and this gate does not claim to fix it.