fix(web): settle subagent entries stuck at "running" after interruption or disconnect#1969
Open
youngting520 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46d65dc369
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
youngting520
force-pushed
the
fix/1963-stale-running-subagents
branch
from
July 20, 2026 15:07
46d65dc to
47d0370
Compare
🦋 Changeset detectedLatest commit: 680e9f3 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 |
youngting520
force-pushed
the
fix/1963-stale-running-subagents
branch
from
July 22, 2026 17:32
47d0370 to
e0aef68
Compare
…on or disconnect Subagent rows could remain running after aborts, rate-limit retries, or disconnects because lifecycle terminals were not consistently emitted and the web client could not reconcile rows missed while offline. Make direct mirrored runs publish failures for aborts and hook errors. Keep retryable 429 attempts non-terminal while the swarm owns the logical subagent, then publish one final failure if it cannot be requeued. Propagate main-turn-independent lifetime through background-agent descendants and make the server roster authoritative for nested live work. The web client now distinguishes roster-owned and REST-owned rows, settles main-turn-bound rows at turn boundaries, and reconciles missed terminals from snapshots without killing legitimate background descendants. Resolve MoonshotAI#1963
youngting520
force-pushed
the
fix/1963-stale-running-subagents
branch
from
July 22, 2026 17:36
e0aef68 to
680e9f3
Compare
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.
Related Issue
Resolve #1963
Problem
Kimi Web builds its live subagent rows from WebSocket lifecycle events. If the client misses a terminal event — for example, when a computer sleeps or the display-off period disconnects the socket and the client later resumes — the local row can remain
runningindefinitely even though the subagent has already finished. A 429 interruption and retry is another way to expose the same lifecycle gap, but it is not the only cause.The underlying reconciliation problem crossed several layers:
/tasks.subagent.failedfor aborts or start-hook failures, while a retryable 429 attempt must remain non-terminal until the swarm scheduler decides the logical subagent is finished.This left completed work visible with a growing timer and made it difficult for users to tell whether an agent was still consuming resources.
What changed
Close the lifecycle and reconciliation gaps at the engine, server, and Web client boundaries:
subagent.failedfor aborts, hook failures, and other errors. A retryable provider 429 emitssubagent.suspendedwithout a premature terminal; retry success emitssubagent.completed, while the scheduler emits one finalsubagent.failedif the last unfinished member cannot be requeued.main_turn_independentthrough background-agent descendants. Main-owned background tasks remain REST-owned, while nested or detached background work stays roster-owned so it survives reconnects and main-turn boundaries until its own lifecycle settles.The result is that stale timers converge after sleep/wake cycles, other disconnects, and live interruptions without terminating or hiding legitimate background subagent trees.
Validation
pnpm --filter @moonshot-ai/agent-core-v2 testpnpm --filter @moonshot-ai/kap-server testpnpm --filter @moonshot-ai/kimi-web testpnpm --filter @moonshot-ai/agent-core-v2 lint:domainpnpm --filter @moonshot-ai/kimi-web check:style(baseline mode)pnpm lint(0 errors; existing repository warnings remain)pnpm changeset status --since=upstream/mainChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.