Skip to content

Commit 0ebe6f3

Browse files
saphidclaude
andcommitted
fix(server): record a failed answer delivery after its session detaches
The failure item took its driver from the provider session binding, so a session detached before the last attempt recorded nothing. The item id no longer depends on the session, and the session only adds provenance when it is still bound. The warning for a failed recording no longer logs the raw cause. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 50d688d commit 0ebe6f3

3 files changed

Lines changed: 295 additions & 278 deletions

File tree

‎apps/server/src/orchestration-v2/EffectWorker.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,10 @@ export const executorLayer: Layer.Layer<
342342
requestId: effect.request.requestId,
343343
})
344344
.pipe(
345-
Effect.catchCause((reopenCause) =>
345+
Effect.catchCause(() =>
346346
Effect.logWarning(
347347
"Failed to record undelivered runtime request answer",
348-
{
349-
effectId: effect.id,
350-
cause: reopenCause,
351-
},
348+
{ effectId: effect.id },
352349
),
353350
),
354351
),

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
RunId,
4545
ThreadLinkedPullRequest,
4646
ThreadId,
47+
TurnItemId,
4748
} from "@t3tools/contracts";
4849
import { modelSelectionsEqual } from "@t3tools/shared/model";
4950
import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
@@ -6796,8 +6797,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
67966797
.getRuntimeResponseContext(command.threadId, command.requestId)
67976798
.pipe(mapDispatchError(command));
67986799
const requestNode = context.node;
6800+
if (context.request === undefined || requestNode === undefined) return;
6801+
// The session may already be detached; the failure is recorded either way.
67996802
const providerSession = context.session;
6800-
if (context.request === undefined || requestNode === undefined || !providerSession) return;
68016803
const thread = yield* projectionStore
68026804
.getThread(command.threadId)
68036805
.pipe(mapDispatchError(command));
@@ -6810,14 +6812,15 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
68106812
threadId: command.threadId,
68116813
...(requestNode.runId === null ? {} : { runId: requestNode.runId }),
68126814
nodeId: requestNode.id,
6813-
driver: providerSession.driver,
6814-
providerInstanceId: providerSession.providerInstanceId,
6815+
...(providerSession === undefined
6816+
? {}
6817+
: {
6818+
driver: providerSession.driver,
6819+
providerInstanceId: providerSession.providerInstanceId,
6820+
}),
68156821
occurredAt: now,
68166822
payload: {
6817-
id: idAllocator.derive.turnItemFromProviderItem({
6818-
driver: providerSession.driver,
6819-
nativeItemId: `runtime-request-delivery-failure:${command.commandId}`,
6820-
}),
6823+
id: TurnItemId.make(`turn-item:runtime-request-delivery-failure:${command.commandId}`),
68216824
threadId: command.threadId,
68226825
runId: requestNode.runId,
68236826
nodeId: requestNode.id,

0 commit comments

Comments
 (0)