-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Improve background agent stability and completion detection #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Gladdonilli
wants to merge
5
commits into
code-yeongyu:dev
from
Gladdonilli:fix/subagent-stability-v2
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5dee9ef
fix: add subagent safety guards and apply PR #655 changes
Gladdonilli 260d49d
fix: clear timeout timer on task completion to prevent memory leak
Gladdonilli 440d9bc
fix: address PR review issues - reset startedAt on resume
Gladdonilli d558a89
fix: prevent double-release and add timeout for resumed tasks
Gladdonilli d59f890
fix: clean up timeout and concurrency on resume error
Gladdonilli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,21 +419,30 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id | |
| metadata: { sessionId: sessionID, category: args.category, sync: true }, | ||
| }) | ||
|
|
||
| try { | ||
| await client.session.prompt({ | ||
| path: { id: sessionID }, | ||
| body: { | ||
| agent: agentToUse, | ||
| system: systemContent, | ||
| tools: { | ||
| task: false, | ||
| sisyphus_task: false, | ||
| }, | ||
| parts: [{ type: "text", text: args.prompt }], | ||
| ...(categoryModel ? { model: categoryModel } : {}), | ||
| // Use fire-and-forget prompt() - awaiting causes JSON parse errors with thinking models | ||
| // For category-based tasks, pass the model from category config | ||
| // For agent-based tasks, use agent's configured model (don't pass model in body) | ||
| let promptError: Error | undefined | ||
| client.session.prompt({ | ||
| path: { id: sessionID }, | ||
| body: { | ||
| agent: agentToUse, | ||
| system: systemContent, | ||
| tools: { | ||
| task: false, | ||
| sisyphus_task: false, | ||
| }, | ||
| }) | ||
| } catch (promptError) { | ||
| parts: [{ type: "text", text: args.prompt }], | ||
| ...(categoryModel ? { model: categoryModel } : {}), | ||
| }, | ||
| }).catch((error) => { | ||
| promptError = error instanceof Error ? error : new Error(String(error)) | ||
| }) | ||
|
|
||
| // Small delay to let the prompt start | ||
| await new Promise(resolve => setTimeout(resolve, 100)) | ||
|
|
||
| if (promptError) { | ||
| if (toastManager && taskId !== undefined) { | ||
| toastManager.removeTask(taskId) | ||
| } | ||
|
Comment on lines
+445
to
448
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt error early return leaves subagentSessions entry uncleared, causing stale session tracking Prompt for AI agents |
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Late prompt rejections are dropped: fire-and-forget prompt is only checked for 100 ms, so failures after that window lead to 10‑minute polling and a misleading "No assistant response found" when the prompt was never sent.
Prompt for AI agents