Skip to content

fix(opencode): keep concurrent task resumes foreground#38758

Open
rekram1-node wants to merge 1 commit into
devfrom
task-resume-race
Open

fix(opencode): keep concurrent task resumes foreground#38758
rekram1-node wants to merge 1 commit into
devfrom
task-resume-race

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

  • keep concurrent foreground resumes attached to the foreground wait path
  • only return an extended task as background when background: true was explicitly requested
  • promote explicit background extensions so completion notification is installed
  • add deterministic coverage for two concurrent foreground resumes of the same task_id

Root cause

TaskTool attempted BackgroundJob.extend before its normal foreground/background branch. Any successful extension returned metadata.background: true, even when background mode was disabled and absent from the tool schema. Because this path also skipped promotion and notify(...), the implicitly background task could finish without injecting its synthetic completion result.

The fix retains BackgroundJob.extend so the second prompt is not dropped and remains serialized behind the active run. A foreground extender now waits for shared job settlement, while only an explicit background extender returns immediately.

Test plan

  • bun test --timeout 30000 test/tool/task.test.ts
  • bun typecheck

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