Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): cancel approval-blocked tools when runs end #22982

Openjuliusmarmingewants to merge 10 commits intomain fromrefs/pull/22982/headopened View on GitHub

Showing 7 changed files with 112 additions and 7 deletions (loading 4).

x
0 of 7 viewed, 7 left
74 additions and 4 deletionsapps/server/src/orchestration-v2/EventSink.tsModified
View file
@@ -117,12 +117,14 @@
"driver" | "providerInstanceId" | "appThreadId" | "nativeThreadRef"
readonly guardPendingUserInputCancellations?: boolean;
+ readonly guardPendingApprovalCancellations?: boolean;
readonly commandId?: CommandId;
readonly events: ReadonlyArray<OrchestrationV2DomainEvent>;
readonly effects: ReadonlyArray<EffectOutbox.PendingOrchestrationEffectV2>;
}) => Effect.Effect<ReadonlyArray<OrchestrationV2StoredEvent>, EventSinkV2Error>;
readonly writeIfRunCurrent: (input: {
readonly guardPendingUserInputCancellations?: boolean;
+ readonly guardPendingApprovalCancellations?: boolean;
readonly commandId?: CommandId;
readonly threadId: ThreadId;
readonly runId: RunId;
@@ -374,6 +376,66 @@
});
});
​
+ // Run finalization cancels approvals it read as pending. One closed since then keeps
+ // its outcome; if it let the tool run, the tool is not marked as never started.
+ const guardApprovalCancellations =
+ /* This helper runs for individual orchestration events; the enclosing operation owns the span. */
+ Effect.fnUntraced(function* (events: ReadonlyArray<OrchestrationV2DomainEvent>) {
+ const staleRequests = new Set<RuntimeRequestId>();
+ const staleNodes = new Set<NodeId>();
+ const startedToolParents = new Set<NodeId>();
+ for (const event of events) {
+ if (