Repository navigation
fix(agent-core-v2): tower mode mistaking newly agents for previous name - #3752
Conversation
…istration Agent ids restart from agent-0 in each session, so a freshly spawned worker collided with the previous session's roster entry and every find-first lookup (caller identity, write guard, death bookkeeping) resolved to the stale entry: workers read the wrong inbox, sent under the wrong name, and were denied their own writes, mission updates, and reviews. - resolveAgent picks the latest roster entry for an agent id; all callers (resolveCallerName, write guard, resume veto, died/revived) go through it - registerAgent retires same-agent-id entries before appending - enter() (/tower on) now adopts the workspace roster itself instead of relying on a manual TowerInit
🦋 Changeset detectedLatest commit: 9cf7e83 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7eaa7ef5f2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
… finds a dead foreign owner A forked or restored session replays the durable TowerModeEnter into an active tower mode without ever calling enter(), so the roster adoption added there never ran on the restore path: with the previous owner session gone, the fork kept the mode (and the stale roster) until a manual TowerInit. The dead-owner branch of the restore-time reconciliation now adopts the workspace, mirroring enter()'s takeover of an idle owner; a live foreign owner still causes an exit.
…dopting its roster Taking tower mode over from a live but idle owner called the owner's synchronous exit(), whose ownership release ran fire-and-forget, and immediately adopted the roster — two concurrent load-modify-save cycles on .tower/comms/state.json that could lose the new owner or resurrect the stale roster. exit() now awaits the ownership release and the takeover awaits the owner's exit(); the remaining callers either await (RPC/HTTP tower-mode-off) or explicitly ignore the promise (mode mutex, restore-time self-exit).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0124c53925
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…nnot complete Adoption failures (unreadable or unpersistable state.json) were swallowed into a log warning, so enter() and the stale-owner restore both activated tower mode with the foreign owner and stale roster still in place — the exact identity mismatch the adoption is meant to prevent, now with a false success report. adoptTowerRoster() now throws a TowerProtocolError with the underlying cause: enter() propagates it before any tool is activated, and the restore path drops the replayed tower mode instead (it must not throw inside the restore hook chain).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a89b66fd98
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…option adopt() treated any state.json read failure as an uninitialized workspace via isInitialized()'s catch-all, so an existing but unreadable state file (EACCES, EISDIR, transient I/O) reported a successful no-op adoption and enter() activated tower mode against the foreign state — bypassing the activation guard added in the previous commit. Only ENOENT now means uninitialized; every other read error propagates into the fail-activation / deactivate-on-restore paths.
- MoonshotAI#3750 loop_control.compaction_max_attempts caps one compaction round's requests (default 5, upstream's, replacing the hardcoded 10) - MoonshotAI#3785 reject an unsupported [secondary_model].default_effort at load time, and surface adaptive_thinking on the catalog model - MoonshotAI#3681 warn on [models] entries missing the model field - MoonshotAI#3752 tower resolves a caller by its last roster entry and retires duplicate agent ids; only ENOENT means an uninitialized workspace - MoonshotAI#3778 evict completed subagent scopes behind an LRU cache (KIMI_CODE_SUBAGENT_SCOPE_CACHE_SIZE, default 32) and rebuild them from the persisted resume record on demand - MoonshotAI#3747 aborting an unknown or already-settled prompt answers 40402 instead of 40903, end to end through the protocol and kimi-web - MoonshotAI#3720/MoonshotAI#3717 scope task notifications by session, so one session's print turn can no longer consume another's completion The allowlist verdicts move to ported where the behavior landed, and ROADMAP 6.1 records the evidence and what stayed open.
Step 5 of the incremental sync to 2.1.1: 14 upstream commits over 230 files. The bulk is the pi-tui re-baseline onto upstream v0.85.1. Upstream's changes in this step, all absorbed: - pi-tui re-baselined on upstream v0.85.1 (MoonshotAI#3780): the native platform modules were consolidated and renamed (darwin-modifiers -> darwin-platform, win32-console-mode -> win32-platform), a Linux/X11 clipboard backend with prebuilds was added, and alt-screen search, autocomplete, editor, input, markdown and the render path were reworked; the native-asset copy scripts and flake.nix follow - the session event bus is sharded by agent id (MoonshotAI#3775) - disposed agent scopes are released from the DI dependency graph (MoonshotAI#3776) - swarm cancellation no longer crashes the CLI (MoonshotAI#3779) - tower mode no longer mistakes newly spawned agents for the previous name (MoonshotAI#3752) - [secondary_model].default_effort fails fast when unsupported (MoonshotAI#3785) - the managed usage payload switched to the quota model (MoonshotAI#3787) - kap-server verifies indexed search results against session sources (MoonshotAI#3631) - web dist synced from code-app (MoonshotAI#3792); docs for the web slash-command table and flat-form skill naming (MoonshotAI#3772, MoonshotAI#3774) Fork behaviour preserved through the re-baseline (pi-tui/UPSTREAM.md): - every `keep` intent card still has a matching per-file diff: the width/grapheme clamps, editor history hooks, multi-root @-completion, inline slash autocomplete, CJK autolink, fullscreen nav fall-through, mouse dispatch (cropped rows, prompt-width clicks, search-field forwarding), and sixel graphics with the startup probe - the fork's image/terminal-image, latex and layout extensions ride on upstream's v0.85.1 baseline - the fork's i18n layer covers the new user-facing strings Verification and the follow-up fixes are recorded in the next commit: the fork's auth-facade test still asserted the pre-quota managed-usage shape, and the node-sdk dts build had lost its i18n specifier rewriting in the 0.42.0 merge (found by this step's root typecheck).
Related Issue
Resolve #(issue_number)
Problem
跨 session 重启 tower mode 导致 agent id 撞号。
tower 给 worker 发消息,inbox 用 id 解析命中了旧名字,最终 worker 收不到。
What changed
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.