-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(background-agent): fix task completion detection for background sessions #592
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
6
commits into
code-yeongyu:dev
from
Gladdonilli:fix/background-task-completion
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51c587d
fix(background-agent): fix task completion detection for background s…
Gladdonilli 6cb31d0
fix: address PR review feedback - remove currentMsgCount > 0 check an…
Gladdonilli e2ade1d
Update src/features/background-agent/manager.ts
Gladdonilli 7851562
feat(background-agent): silent notifications + fix output extraction
Gladdonilli 74bd39c
fix: clear task.model after release to prevent double-release
Gladdonilli 7cdeba1
fix(background-agent): use minimum time threshold for stability detec…
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -452,11 +452,13 @@ export class BackgroundManager { | |||||
| const sessionStatus = allStatuses[task.sessionID] | ||||||
|
|
||||||
| if (!sessionStatus) { | ||||||
| log("[background-agent] Session not found in status:", task.sessionID) | ||||||
| continue | ||||||
| // Note: Background sessions may not appear in session.status() | ||||||
| // Don't skip - fall through to message-based stability detection | ||||||
| log("[background-agent] Session not found in status, checking via messages:", task.sessionID) | ||||||
| // Removed: early continue that skipped completion logic | ||||||
| } | ||||||
|
|
||||||
| if (sessionStatus.type === "idle") { | ||||||
| if (sessionStatus?.type === "idle") { | ||||||
| const hasIncompleteTodos = await this.checkSessionTodos(task.sessionID) | ||||||
| if (hasIncompleteTodos) { | ||||||
| log("[background-agent] Task has incomplete todos via polling, waiting:", task.id) | ||||||
|
|
@@ -504,6 +506,25 @@ export class BackgroundManager { | |||||
| if (!task.progress) { | ||||||
| task.progress = { toolCalls: 0, lastUpdate: new Date() } | ||||||
| } | ||||||
|
|
||||||
| // Stability detection: if message count unchanged for 3 polls, consider complete | ||||||
| const currentMsgCount = messages.length | ||||||
| const progress = task.progress as { stableCount?: number; lastMsgCount?: number } | ||||||
| if (progress.lastMsgCount === currentMsgCount && currentMsgCount > 0) { | ||||||
|
||||||
| if (progress.lastMsgCount === currentMsgCount && currentMsgCount > 0) { | |
| if (progress.lastMsgCount === currentMsgCount) { |
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Oops, something went wrong.
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.
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.
stableCountandlastMsgCountnot inTaskProgresstype - extend the type intypes.tsto include these fields