Skip to content

🪡 fix: Leave Child-Thread Runs Out of the Active Chat List - #18167

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/active-chats-skip-child-threads
Nov 14, 2026
Merged

danny-avila merged 1 commit into
devfrom
danny-avila/active-chats-skip-child-threads

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

GET /api/agents/chat/active returns every generation job the user owns, and the sidebar treats each id as a running chat. An event-bound subagent child runs as a generation job keyed by its child thread id (request.js sets streamId = conversationId), so that id is in the list for as long as the child runs. A child thread is not a listed conversation: the sidebar finds no row for the id, asks for the conversation and its share link, gets 404 (packages/api/src/conversations/load.ts), stores null, and useRunningConversationsQuery retries a null every two seconds.

This PR leaves child-thread jobs out of the active list. The job still answers its own /chat/status and /chat/stream reads, and owner cleanup still counts it, so deletion and account drains are unchanged. The abort route's new placeholder fallback reads the same list, so a running child no longer counts as a candidate there either.

The server half is covered by the tests below. The sidebar's retry loop is read from the client code, not observed in a running app.

This is the first slice of the subagent stream work: later slices give background children a job of their own, and this is the rule that keeps those ids out of the sidebar.

How it works

The stores stay unaware of what a child thread is. getActiveJobIdsByUser takes an optional filter, applied where the store already holds the job, so the list costs no extra reads. The manager supplies the policy.

 async getActiveJobIdsForUser(userId: string, tenantId?: string): Promise<string[]> {
-  return this.jobStore.getActiveJobIdsByUser(userId, tenantId);
+  return this.jobStore.getActiveJobIdsByUser(userId, tenantId, isListedChatJob);
 }

A job is a child-thread job when it carries agentEventBindingId: an event binding always targets a reserved child thread. isChildThreadJob in packages/api/src/stream/metadata.ts is the one place that decides it.

GET /chat/active
  GenerationJobManager.getActiveJobIdsForUser      # passes isListedChatJob
    jobStore.getActiveJobIdsByUser(…, accept)      # filter applied per tracked job
      getCleanupBlockingJobIdsByUser               # unfiltered: child jobs still drain

Type of change

  • Bug fix

Testing

Tested environments/configuration:

  • In-memory job store through the real GenerationJobManagerClass
  • Redis job store against a local Redis 127.0.0.1:6379

Automated tests:

  • Added packages/api/src/stream/__tests__/childThreadJobs.spec.ts: a running child thread is left out of the active list, stays in the unfiltered store read, still answers getJob, and still blocks owner cleanup. With the filter removed, the two list assertions fail.
  • Added one case to RedisJobStore.stream_integration.spec.ts for the same filter on the Redis store.
  • Ran the existing specs that exercise active-job enumeration: jobStoreCapabilities, createJobOwnership, staleJobReaping, pendingAction, terminalHostAction, idempotencyClaim, startup (305 tests pass).
  • npx tsc --noEmit in packages/api, and npm run static-checks -- --against origin/dev.

An event-bound subagent child runs as a generation job keyed by its child
thread id, so GET /chat/active returned that id beside the user's chats. The
sidebar has no row for it, looks the conversation up, gets 404, and asks again
every two seconds for as long as the child runs.

The manager's active-job read now takes a filter and leaves child-thread jobs
out. The job still answers its own status and stream reads, and owner cleanup
still counts it.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review the latest head, final review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T19:02:52.932289Z 84fe477 Manual request
ℹ️ 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 84fe47740f

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

@danny-avila
danny-avila marked this pull request as ready for review November 14, 2026 20:01
@danny-avila
danny-avila merged commit 929f05d into dev Nov 14, 2026
57 of 58 checks passed
@danny-avila
danny-avila deleted the danny-avila/active-chats-skip-child-threads branch November 14, 2026 20:01
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.

1 participant