(
continuation: RuntimeContinuation,
execution: PendingExecutionClaim,
options: ResumeContinuationOptions,
)
| 750 | } |
| 751 | |
| 752 | private async *resumeContinuationClaimed( |
| 753 | continuation: RuntimeContinuation, |
| 754 | execution: PendingExecutionClaim, |
| 755 | options: ResumeContinuationOptions, |
| 756 | ): AsyncIterable<SessionEvent> { |
| 757 | await this.enterExecutionClaim(execution); |
| 758 | if (!this.deps.runStore || !this.deps.runtimeEventStore) { |
| 759 | throw new Error('Runtime continuation requires AgentRunStore and RuntimeEventStore'); |
| 760 | } |
| 761 | const continuationAuthority = requireRuntimeContinuationAuthority(this.deps.runtimeEventStore); |
| 762 | if ( |
| 763 | this.hasActiveRuns(continuation.sessionId) || |
| 764 | (this.executionClaims.get(continuation.sessionId)?.size ?? 0) > 1 |
| 765 | ) { |
| 766 | throw new Error('Cannot continue while another run is active'); |
| 767 | } |
| 768 | |
| 769 | const header = await this.deps.store.readHeader(continuation.sessionId); |
| 770 | const sourceRun = await this.deps.runStore.readRun( |
| 771 | continuation.sessionId, |
| 772 | continuation.sourceRunId, |
| 773 | ); |
| 774 | const sourceEvents = await revalidateContinuationBoundary(continuationAuthority, continuation); |
| 775 | assertContinuationSourceUnchanged(continuation, sourceRun, sourceEvents); |
| 776 | await this.revalidateContinuationSafety(continuation); |
| 777 | |
| 778 | const userInput: UserMessageInput = { |
| 779 | turnId: continuation.turnId, |
| 780 | text: '', |
| 781 | parentRunId: continuation.sourceRunId, |
| 782 | parentTurnId: continuation.sourceTurnId, |
| 783 | }; |
| 784 | const effectiveOrchestration = effectiveOrchestrationForRun(sourceRun, header); |
| 785 | const effectiveToolMode = effectiveToolModeForRun(sourceRun); |
| 786 | const claimedAt = this.deps.now(); |
| 787 | const targetRunHeader = continuationTargetRunHeaderForExecution({ |
| 788 | continuation, |
| 789 | sessionHeader: header, |
| 790 | userInput, |
| 791 | workspaceIdentity: continuation.safetySnapshot.workspaceIdentity, |
| 792 | effectiveOrchestration, |
| 793 | effectiveToolMode, |
| 794 | claimedAt, |
| 795 | }); |
| 796 | const claim = continuationClaimForExecution(continuation, claimedAt, targetRunHeader); |
| 797 | const claimResult = await continuationAuthority.claimContinuation({ claim }); |
| 798 | if (claimResult.kind !== 'acquired') { |
| 799 | throw new RuntimeContinuationRevalidationError( |
| 800 | 'continuation_claim_conflict', |
| 801 | `Runtime continuation boundary is already claimed by ${claimResult.claim.claimId}`, |
| 802 | ); |
| 803 | } |
| 804 | await this.deps.continuationFailpoint?.('after_continuation_claim_committed'); |
| 805 | |
| 806 | const sessionRuns = await this.deps.runStore.listSessionRuns(continuation.sessionId); |
| 807 | const existingClaim = sessionRuns.find( |
| 808 | (runHeader) => |
| 809 | runHeader.continuationSource?.sourceRunId === continuation.sourceRunId && |
no test coverage detected