Repository navigation
🪡 fix: Leave Child-Thread Runs Out of the Active Chat List - #18167
Merged
Merged
Conversation
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.
Collaborator
Author
|
@codex review the latest head, final review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
Summary
GET /api/agents/chat/activereturns 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.jssetsstreamId = 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), storesnull, anduseRunningConversationsQueryretries anullevery two seconds.This PR leaves child-thread jobs out of the active list. The job still answers its own
/chat/statusand/chat/streamreads, and owner cleanup still counts it, so deletion and account drains are unchanged. The abort route'snewplaceholder 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.
getActiveJobIdsByUsertakes 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.isChildThreadJobinpackages/api/src/stream/metadata.tsis the one place that decides it.Type of change
Testing
Tested environments/configuration:
GenerationJobManagerClassAutomated tests:
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 answersgetJob, and still blocks owner cleanup. With the filter removed, the two list assertions fail.RedisJobStore.stream_integration.spec.tsfor the same filter on the Redis store.jobStoreCapabilities,createJobOwnership,staleJobReaping,pendingAction,terminalHostAction,idempotencyClaim,startup(305 tests pass).npx tsc --noEmitinpackages/api, andnpm run static-checks -- --against origin/dev.