Skip to content

run: background-launch dedupe keyed only by sessionID mis-attributes resumed/concurrent runs (headless exits early) #400

Closed

Description

@mdev34-lab

Severity: medium | global review pass P3. Extends #342 (re-emitted launch parts) and relates to #343 (metadata copy detaching review-loop metadata).

packages/opencode/src/cli/cmd/run/background-tasks.ts:14: launched is Map<sessionID,parentID> keyed only by sessionID. Two concurrent launches of the same sessionID from different parents (nested subagent race) dedupe to the first parent: known(id) returns false for the second branch and pending() under-counts, so the headless run exits early (run.ts:753 settled() guard). The authoritative run key is [email protected]_at (tool/task.ts:40) - ignored here. Resumed runs via task_id resume (tool/task.ts:717) collapse into the same key. And if launch dedupe drops a re-emitted part, the #343 metadata (projectWrites clones metadata by reference at task.ts:400, merged later at processor.ts:208) never gets projected as writesFiles evidence.

Repro: two parallel task calls that both task_id-resume the same prior session (or a fast descendant chain emitting sessionId before its parent); background.pending().length is 1 instead of 2 and the headless run exits while a child still runs. Fix size: medium (key by sessionID@started_at, include parent id, add run-id to the launch event schema).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions