Repository navigation
fix(native-chat): keep chats with untracked helpers during idle cleanup - #28812
brennanb2025 wants to merge 3 commits into
Conversation
ddd38c5 to
05a4c08
Compare
…rederive' into brennanb2025/sta-10504-idle-sweep-incomplete # Conflicts: # src/main/native-chat/agent-session-wire/structured-agent-session-conversation-lifetime.ts # src/main/native-chat/agent-session-wire/structured-agent-session-idle-sweep.ts
…2025/sta-10504-idle-sweep-incomplete
Review loop status: code review passed, CI green, QA passedProblem. Orca's agent-status store holds at most 8,192 helper (subagent) records per host. Once it is full, it refuses records for new helpers. Native chat's idle cleanup, which stops a chat's agent after 30 quiet minutes, only looked at admitted records, so it could stop a chat's agent while a refused helper was still working. The user would see the helper's work cut off for no visible reason. User-facing change. In that case, the chat now keeps running until the helper ends or you press Stop, and then normal idle cleanup resumes. Ordinary chats behave exactly as before; nothing new appears in the UI. What was fixed. Idle cleanup now reads the host's existing "child tracking incomplete" signal. The base PR #28829 makes that signal exact, so it clears when the last refused helper ends. Review found two problems in earlier versions, both fixed in #28829: an old 512-helper overflow marker that stayed set after every helper ended, which would have blocked idle cleanup forever, and a proposed 24-hour expiry that could have forgotten a helper that was still working. Nothing is deferred. What was verified.
Not verified / remaining risks.
|
|
Closing: this patches the status store's size limits, which are themselves wrong. The fix is moving to the root of that store in a separate change. |
ELI5
When the agent-status store fills up (it holds at most 8,192 helper records), it can refuse the record for a background helper that is still working. Native chat's 30-minute idle cleanup then sees no helper and can stop the chat's agent while that helper is mid-task.
With this change, the chat stays running while that helper works. Once the helper ends, the normal idle window applies again, and the existing Stop action still ends the agent immediately.
What Changed
The idle sweep now reads the host's existing per-session signal that child-work tracking is incomplete, and treats it as work still owed. The prerequisite fix, #28829, makes that signal exact: it remembers every refused helper until that helper is admitted, ends, or its provider session ends. No new notice, control, saved field, or wire message is added.
User-facing before and after:
Why
The sweep previously read only the child rows admitted to the status store, so a refused live helper was invisible to it. The execution host already receives the helper's identity and end event even when its display row is refused; reading that lifecycle information closes the gap with five small file changes (+12/-2) and no new state.
How this differs from the common pattern (INTENDED): the common pattern derives owed child work from one provider-reported roster of children. Here, admitted children live in the bounded display status store and the exact set of refused helpers is kept beside it by the execution host. Intended because generic ACP agents expose no helper signal and Grok exposes only bounded projections, so the exact refused-helper set is the host-owned truth under the display store's cap. Both paths settle on the child's own end event or the provider session's end. A provider-reported child-work model that gives the sweep one execution-owned source for every child is a possible later refactor; it would be a broader per-provider change than this rare case needs.
Linked Issue
STA-10504
Visual Proof
The fault state itself (8,192 tracked helpers plus 30 idle minutes) is not practical to drive live; it is covered by the real-store test described under Testing. The screenshots below prove ordinary chats did not change: hidden-window QA on a separate Mac (M4Air), with real Claude Code 2.1.301 signed in and Grok driving the app over the Chrome DevTools Protocol, comparing
origin/main(de2a371) with this PR at commit 05a4c08. The later commits only merge in current main; main had rewritten the idle sweep's work check, so the same two added lines were re-applied onto main's version, and a separate review confirmed no behavior difference. Each build ran in its own throwaway home with background launch; the real agent config files hashed identically before and after.Result: no user-visible difference caused by this PR for (a) a short prompt, (b) a long command stopped with Stop, which reads "Interrupted" and then accepts the next prompt normally, and (c) one subagent.
Notes on the differences you can see:
Testing
The execution host owns this check for local, folder, and SSH workspaces; no platform path or wire contract changes. Linux and Windows are covered by CI only.
Review
Three adversarial review rounds plus an architecture challenge, and one more review of the conflict resolution after main was merged in. They found that the old 512-helper overflow marker could leave a false "incomplete" signal after every helper had ended, which would have blocked idle cleanup forever, and that a proposed 24-hour expiry could instead drop a helper that was still working. Both are fixed in #28829 by tracking the exact refused helpers. No open correctness findings remain.
Agent skill upstream boundary
Notes
Stacked on #28829 (this PR's base branch). The two commits together fix the premature idle stop and the incomplete-tracking strip that used to stay up after more than 512 refused helpers had all ended.
Checklist