feat(run-tracking): store BullMQ jobId immediately after run creation#776
Merged
feat(run-tracking): store BullMQ jobId immediately after run creation#776
Conversation
nhopeatall
approved these changes
Mar 13, 2026
Collaborator
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
LGTM — Clean, well-scoped change that stores the BullMQ jobId on the run record immediately after creation, enabling the cancel flow mapping. The implementation correctly follows the existing fire-and-forget error handling pattern used throughout runTracking.ts.
Verified:
updateRunJobIdexists inrunsRepository.tsand performs a straightforward DB update on thejobIdcolumn (confirmed in schema atsrc/db/schema/runs.ts:36)JOB_IDenv var is confirmed set bybuildWorkerEnv()incontainer-manager.ts:81- Inner try/catch correctly isolates jobId storage failure from run creation — the run ID is still returned even if
updateRunJobIdthrows - Guard on
process.env.JOB_IDcorrectly skips the update in local dev / non-Docker mode - Tests cover all three paths: happy path, absent env var, and failure resilience
- All CI checks pass
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Store the BullMQ jobId on the agent_runs record immediately after run creation in the worker container. This enables the cancel flow mapping (runId → jobId → container) needed for the cancel listener implementation.
Implementation Details
tryCreateRun()insrc/agents/shared/runTracking.tsto callupdateRunJobId(runId, process.env.JOB_ID)after successful run creationbuildWorkerEnv()in container-manager.tsTesting
Added comprehensive unit tests to verify:
Verification
Closes: https://trello.com/c/afFdwvgk/304-as-a-developer-i-want-the-worker-to-store-its-bullmq-jobid-on-the-run-record-so-that-cancel-commands-can-map-runs-to-containers