Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/runtime/retained-run-binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ export function assertInteractionBinding(
controlRef: AgentExactRunControlRef,
command: InteractionResponseCommand,
): void {
// This digest identifies the interaction request, not the retained turn.
// The provider validates it against its durable interaction record.
if (
command.binding.runId !== controlRef.runId ||
command.binding.provider !== controlRef.provider ||
command.binding.environmentId !== controlRef.environmentId ||
command.binding.sessionId !== controlRef.sessionId ||
command.binding.executionId !== controlRef.executionId ||
command.binding.requestDigest !== controlRef.requestDigest
command.binding.executionId !== controlRef.executionId
) {
throw new Error('interaction response command does not target this retained run')
}
Expand Down
9 changes: 8 additions & 1 deletion tests/helpers/retained-run-child.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ if (phase === 'start') {
const events = []
for await (const event of run.events({ after: reference.after })) events.push(event)
const statusBefore = await run.status()
const interactionEvent = events.find((event) => event.event.type === 'interaction')?.event
if (interactionEvent?.type !== 'interaction') {
throw new Error('retained provider replayed no interaction request')
}
if (interactionEvent.request.requestDigest === run.controlRef.requestDigest) {
throw new Error('interaction request digest unexpectedly matched the retained turn digest')
}
const interactionBinding = {
runId: run.controlRef.runId,
provider: run.controlRef.provider,
environmentId: run.controlRef.environmentId,
sessionId: run.controlRef.sessionId,
executionId: run.controlRef.executionId,
interactionId: 'interaction-1',
requestDigest: run.controlRef.requestDigest,
requestDigest: interactionEvent.request.requestDigest,
}
const interactionResponse = { id: 'interaction-1', outcome: 'accepted' as const }
const interaction = await run.respondToInteraction({
Expand Down