Skip to content

fix(run): key background launch tracking by run, not session (#400) - #463

Merged
agenteinstinct1-max merged 1 commit into
dev-vibecodedfrom
fix/background-run-key-dedupe
Oct 21, 2026
Merged

agenteinstinct1-max merged 1 commit into
dev-vibecodedfrom
fix/background-run-key-dedupe

Conversation

@agenteinstinct1-max

Copy link
Copy Markdown
Collaborator

Closes #400.

The headless background-task tracker keyed launched sessions by sessionID alone: two runs of one session (a task_id resume, or a re-emitted launch part racing a resolve) collapsed into one pending entry, and a terminal envelope for an earlier run could settle a later one, so opencode run could exit while a child was still running. The authoritative run key ([email protected]_at) existed in the job registry but never reached the tracker.

  • Launch parts now carry runId (sessionID@started_at) in their metadata on all three launch paths (immediate background, extend, promote)
  • Terminal <task> envelopes carry the run key as a run attribute; the headless loop resolves by it, falling back to the session ID for envelopes without one (older servers, attach mode)
  • The tracker keys pending deliveries by run id; attribution walks still use latest-launch-per-session

Tests: 3 new tracker cases (concurrent runs of one session both pending, stale envelope does not settle a resumed run, re-emitted launch dedupes); delivery-envelope assertions updated to expect the run attribute. bun test test/cli/run/ 229 pass, bun test test/tool/task.test.ts 65 pass.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

The headless background-task tracker keyed launched sessions by
sessionID alone, so two runs of one session (a task_id resume, or a
re-emitted launch racing a resolve) collapsed into one pending entry
and a terminal envelope for an earlier run could settle a later one,
letting headless runs exit while a child was still running.

- Stamp every background launch's part metadata with runId
  (sessionID@started_at, the registry's run key) on the start, extend,
  and promote paths
- Carry the run key on terminal <task> envelopes as a run attribute
- Key the tracker's pending set by run id, falling back to the session
  ID for envelopes without one (older servers, attach mode)
@agenteinstinct1-max
agenteinstinct1-max force-pushed the fix/background-run-key-dedupe branch from 20fbc8d to 91d3eca Compare October 21, 2026 08:15
@kilo-code-bot

kilo-code-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (5 files)
  • packages/opencode/src/cli/cmd/run.ts - No issues
  • packages/opencode/src/cli/cmd/run/background-tasks.ts - No issues
  • packages/opencode/src/tool/task.ts - No issues
  • packages/opencode/test/cli/run/background-tasks.test.ts - No issues
  • packages/opencode/test/tool/task.test.ts - No issues

Reviewed by free · Input: 81.9K · Output: 3.2K · Cached: 379.9K

@agenteinstinct1-max
agenteinstinct1-max merged commit 6a4a3e6 into dev-vibecoded Oct 21, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant