Skip to content

Keep idle Claude CLIs with background subagents alive; show their progress between turns (#1443, #1522) - #1547

Merged
currentbits merged 2 commits into
mainfrom
coder/1443-1522-claude-background-subagents-b4d6d8
Oct 9, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/1443-1522-claude-background-subagents-b4d6d8

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #1443. Closes #1522.

#1443 (422e2d6): idle reaping (both the cap of 3 idle CLIs and the 30-min timer) killed Claude CLIs that were still running background subagents, then marked those subagents done.

  • runner-claude-sessions.js: the cap sweep skips sessions whose thread has a running subagent, and the timer re-checks instead of disposing them. The exemption lapses 2 h after the session went idle, so a lost task-notification can't keep a session alive forever.
  • runner-subagents.js: when the last running subagent settles, scheduleClaudeIdleReap runs again. finishRunningSubagents now marks killed work failed; a run that ends normally passes done (Cursor). A crashed Claude CLI also settles its subagents.

#1522 (7481c1c): between turns, events from an idle CLI were dropped at the guard. The new ingestSubagentEvent folds task_started, task_progress and task_notification system events, plus messages stamped with parent_tool_use_id, onto the running row's activity. The Agents panel shows it as last activity. SubagentInfo.activity is added to src/shared/ipc.ts.

Tests: new fake-claude scenarios in electron/test/claude.test.js. Electron: 4351 pass, 0 fail (clean env). Renderer: 2882 pass, 0 fail. tsc --noEmit is clean. The memory-server suite has 3 failures in the #409 injection-scan test, which fail the same way on main.

Part of the #1532 gap pass.

🤖 Generated with Claude Code

Willem and others added 2 commits October 9, 2026 13:17
…#1443)

The idle cap and the 30-min reap skip a session whose thread has a running
subagent; the exemption lapses 2h after the session went idle so a lost
task-notification can't pin it forever. When the last subagent settles the
reaper re-arms. Subagents killed with their CLI (reap, quit, crash, stop) now
settle as "failed" instead of "done"; a cursor run that exits normally
still settles its rows as done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The idle CLI's system task_started/task_progress events (and the agent's
parent_tool_use_id-stamped tool calls) for a running subagent now land on its
row as `activity`, which the Agents panel shows as the row's last-activity
line. A structured system task_notification settles the row and re-arms the
idle reaper. Events that match no running subagent still hit the guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T12:48:58.670194Z 7481c1c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7481c1c32f

ℹ️ 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".

if (fresh) sess.idleSince = Date.now();
else clearTimeout(sess.idleTimer);
armIdleTimer(threadId, sess);
if (!fresh) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-run the idle-cap sweep when a pin is released

When more than three sessions are retained because all are pinned, settling one subagent invokes this function with an existing idle timer, so this early return skips the cap sweep below. The newly unpinned session therefore remains alive for another full idle timeout even though the map is already above CLAUDE_IDLE_MAX; re-evaluate the cap when an existing pinned timer is re-armed.

Useful? React with 👍 / 👎.

Comment on lines +183 to +188
if (system && (ev.subtype === "task_progress" || ev.subtype === "task_started")) {
text =
(typeof ev.summary === "string" && ev.summary) ||
(typeof ev.last_tool_name === "string" && ev.last_tool_name
? `Using ${ev.last_tool_name}`
: null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record descriptions from task-started events

A task_started event can contain only description for its human-readable progress—the new test fixture itself emits exactly that shape—but this branch reads only summary and last_tool_name. Until a later tool call or progress event arrives, no activity is stored or pushed, so the Agents panel fails to show that the background subagent started; use description as the fallback for task_started.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit bb4fb48 into main Oct 9, 2026
6 checks passed
@currentbits
currentbits deleted the coder/1443-1522-claude-background-subagents-b4d6d8 branch October 9, 2026 14:11
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.

P2: Background subagent progress between turns is dropped (Claude) Don't reap idle Claude sessions that still run background subagents

1 participant