Correlate question answers back to the question that asked them - #501
Merged
TheGreatAxios merged 4 commits intoAug 30, 2026
Merged
Conversation
Proves the block's own id (the same id postQuestion mints as questionId) rides an answer's mail as its correlationId end to end through the real HTTP route, including when batching would otherwise strand it: a batch whose last queued message isn't the answer itself must still carry the answer's correlationId, not drop it because the last message has none.
postQuestion minted a stable questionId that runAskUser discarded, and the question-response route set no interchangeCorrelationId on the relayed answer, so nothing tied answer N to question N beyond arrival order — two questions asked before either was answered would resolve on a guess, not a match. ask_user's beforeToolExtension (CL-7190, stacked below this) already reuses questionId as its message_response gate's correlationId; this wires the other half of the round trip. The blocks/responses route now passes the answered block's own id (which IS its questionId, the same way a poll's block id is its pollId) as correlationId when relaying a question's answer. That id threads through the plain-message mail path — SendWorkbenchMessageInput -> QueuedTurn -> dispatchTurnBatch -> DispatchTurnInput/dispatchTurn -> WorkbenchMail.sendMail -> platform-adapter -> SendFoldedMailParams/deliverFoldedMailMIME -> UserMessageParams/sendUserMessage -- landing as headers.interchangeCorrelationId on the InboundMessage the reactor's pre-existing, unmodified tryCorrelate already reads generically. dispatchTurnBatch takes whichever queued turn in a batch carries a correlationId, not only the batch's last message, since principalId legitimately tracks "whoever sent last" but a gate answer does not.
Records the UserMessageParams.correlationId delta in VENDORED.md and vendor/intx/hub-sessions/VENDORED-FROM, with a matching tree-hash update in scripts/checks/kill-dates.txt.
6 tasks
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
Stacked on #500 (CL-7190).
postQuestionmints a stablequestionIdand returns{ messageId, questionId }— its own doc comment claimed a caller could correlate a later answer with it, butrunAskUsercalledpostQuestionas a bare statement and discarded the return entirely. On the answering side, a question response was relayed as an ordinarysendWorkbenchMessagewith nointerchangeCorrelationId, so the reactor'stryCorrelate(unmodified, pre-existing) had nothing to match against a parkedmessage_responsegate — an answer was just "the next thing the user said." An agent asking two questions before either was answered would apply the wrong answer to the wrong one.beforeAskUser(CL-7190) already reusespostQuestion'squestionIdas its gate'scorrelationId. This PR wires the other half: the blocks/responses route now passes the answered block's own id ascorrelationIdwhen relaying a question's answer — verified that for a question block,blockIdis itsquestionIdverbatim, the same way a poll's block id is itspollId(packages/chat/src/schema.ts'sblock_responsestable comment).SendWorkbenchMessageInput→QueuedTurn→dispatchTurnBatch→DispatchTurnInput/dispatchTurn→WorkbenchMail.sendMail→platform-adapter.ts→SendFoldedMailParams/deliverFoldedMailMIME→UserMessageParams/sendUserMessage, landing asheaders.interchangeCorrelationId— the exact headertryCorrelatealready reads generically, no reactor change needed.dispatchTurnBatchinitially tooklast.correlationId(mirroring how it already takeslast.principalId), but a Critique pass found this drops the correlation entirely when the answer isn't the batch's last queued message (e.g. an unrelated follow-up queues behind it before the batch drains) — silently degrading to timeout-only resolution instead of the documented "whole blob still resolves" limitation. Fixed to take whichever queued turn in the batch carries a correlationId, with a regression test proving it.postQuestion's stale doc comment (claiming the tool result "names" the id) is corrected.Test plan
cd packages/interaction-tools && bun run typecheck && bun test— 11/11 passcd packages/folded-runs && bun run typecheck && bun test— 61/61 passcd vendor/intx/hub-sessions && bun run typecheck && bun test— 44/44 passcd packages/chat && bun run typecheck && bun test— 724/724 pass (37 skip, pre-existing)bun run check:killdates,check:tool-package-pins,check:tool-package-freshness,check:licenses,check:deletion,check:browser-safe-subpaths— all passbunx prettier --checkon every touched fileInterchange notes
No upstream Interchange defect.
tryCorrelate/reactor correlation matching (vendor/intx/inference/src/reactor.ts) is untouched by this PR — it already readheaders.interchangeCorrelationIdgenerically; the gap was entirely in this repo's ownpackages/chat/packages/folded-runsmail-dispatch chain and one vendoredhub-sessionsfield (UserMessageParams.correlationId) that hardcodedundefined.A related, narrower architectural note (a crash-window race between
postQuestion's external POST and the gate's durable commit) was filed separately as CL-7248 — out of scope for both this PR and CL-7190.DO NOT MERGE — review together with #500; this branch depends on it.
Closes CL-7191.