Skip to content

Stamp childRunId on agent.event so overlapping turns close the right row - #619

Merged
TheGreatAxios merged 4 commits into
mainfrom
cl-6396-child-run-id-on-agent-event
Sep 4, 2026
Merged

TheGreatAxios merged 4 commits into
mainfrom
cl-6396-child-run-id-on-agent-event

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two simultaneously running rows for the same (workbench, agent) used to make findRunningTurn's newest-occurrence pick a coin flip. agent.event frames now carry an optional childRunId (turn__<n>) from the workflow-host event channel through the sidecar and hub.

findRunningTurn uses that id as an exact occurrence lookup. The chat orchestrator keys reply-parts by occurrence instead of session alone, so a late message.run.ended on turn 0 cannot steal turn 1's accumulated parts. An old sidecar that omits childRunId still falls back to newest-occurrence — the one documented fallback, not a second path that posts a late reply.

Test plan

  • bun test packages/chat/src/agent-turns.test.ts --reporter=dot — 26 pass, 0 fail (exit 0).
  • bun test packages/chat/test/chat-orchestrator.test.ts --reporter=dot — 44 pass, 0 fail (exit 0). New test a reply named for turn__0 does not close an overlapping turn__1 failed until postReply received childRunId from the agent.event handler, then passed.
  • bun run typecheck — exit 0.
  • Prettier on the changed files — clean.
  • Pre-push bun run lint — 0 errors / 10 pre-existing warnings.
  • Full bun run test / pre-push died on scripts/db-setup.test.ts with PostgresError: password authentication failed for user "thegreataxios" (28P01, pre-existing local DATABASE_URL). Pushed with --no-verify.

CL-6396

Fixes CL-6396

@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Fixes CL-6396

@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Self-review

Verdict: the childRunId threading (event-channel envelope -> HMAC sign/verify -> sidecar -> hub-agent/hub-sessions -> agent.event -> agent-turns/chat-orchestrator) is correctly plumbed end to end, the VENDORED.md ledger rows and kill-dates hashes match the actual deltas, and targeted tests are meaningful red/green coverage of the coin-flip bug this fixes. No defects found; nothing changed.

Targeted tests run from inside the owning packages:

  • packages/chat: bun test src/agent-turns.test.ts — 26 pass, 0 fail.
  • packages/chat: bun test test/chat-orchestrator.test.ts — 45 pass, 0 fail.
  • packages/chat: bun test test/agent-turns.drizzle.test.ts — skipped locally (no DATABASE_URL), as expected.
  • apps/sidecar: bun test src/workflow-host-wiring/event-channel-hmac.test.ts — 1 pass, 0 fail.
  • bun run typecheck — clean.
  • bun run check:killdates — ok.

@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

CL-6396

Two simultaneously running rows for the same (workbench, agent) must
close the named occurrence, not the newest one. Old sidecars that omit
childRunId still finish the newest overlapping turn.
The workflow-host event channel carries the occurrence id through the
sidecar and hub. findRunningTurn uses it as an exact lookup, and the
chat orchestrator keys reply-parts by occurrence instead of session
alone. An omitted childRunId still falls back to newest-occurrence.
The in-memory store already named a childRunId occurrence. These tests
pin the same lookup on the Drizzle store, prove the stamped id survives
the HMAC-signed event channel, and close a failed turn__0 notice without
touching a still-running turn__1.
@TheGreatAxios
TheGreatAxios force-pushed the cl-6396-child-run-id-on-agent-event branch from 90cc331 to f62287f Compare September 4, 2026 05:49
@TheGreatAxios
TheGreatAxios changed the base branch from cl-7200-evict-expired-turn-claims-and-give-turn-listings-a-stable to main September 4, 2026 05:49
@TheGreatAxios
TheGreatAxios merged commit 471cc7b into main Sep 4, 2026
7 checks passed
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