Skip to content

fix: wait_for_jobs can return the wrong run because queue_agent discards the triggered run ID#831

Closed
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-90a31c9c
Closed

fix: wait_for_jobs can return the wrong run because queue_agent discards the triggered run ID#831
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-90a31c9c

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • queue_agent now preserves the run ID returned by the jobs-v2 trigger endpoint and includes it in its JSON result alongside the job ID
  • wait_for_jobs now accepts run_ids and, when provided, polls /v2/runs/{run_id} so it waits on the exact triggered run instead of whichever run is latest for the job
  • kept job_ids support for backwards compatibility and added a focused test covering the exact-run polling path

Why this is high-value

This fixes a user-visible reliability bug on the queued sub-agent path. Before this change, if the same queued job was triggered again before wait_for_jobs finished polling, the waiter could attach to the newer run and return the wrong status/output. Returning and consuming the trigger's run ID removes that ambiguity and prevents result corruption.

Validation

  • gofmt -w internal/tools/queue_agent.go internal/tools/queue_agent_test.go
  • go build ./...
  • go test ./...
  • git diff --check

@SamSaffron

Copy link
Copy Markdown
Owner

Closing as requested: the high-confidence fixes have been applied or superseded in the current working tree.

@SamSaffron SamSaffron closed this Jun 18, 2026
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.

2 participants