TypeScript
fix(server): show readable provider runtime failure banners (#24614)
Julius Marmingef3b0194c7b43
diff --git a/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts b/apps/server/src/orchestration-v2/ProviderSessionManager.test.tsindex cac8e4fbbb8..86b173f80dc 100644--- a/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts+++ b/apps/server/src/orchestration-v2/ProviderSessionManager.test.ts@@ -2551,6 +2551,10 @@ it.effect("ProviderSessionManagerV2 releases sessions when provider event streamassert.isTrue(Option.isNone(liveSession));assert.equal(runtimeState.closeCount, 1);assert.equal(projection.providerSessions.at(-1)?.status, "error");+ assert.equal(+ projection.providerSessions.at(-1)?.lastError,+ "The provider event stream closed unexpectedly. Retry the turn; if it keeps failing, check the provider and server logs.",+ );});yield* effect.pipe(diff --git a/apps/server/src/orchestration-v2/ProviderSessionManager.ts b/apps/server/src/orchestration-v2/ProviderSessionManager.tsindex df2ee630df3..b9887a48446 100644--- a/apps/server/src/orchestration-v2/ProviderSessionManager.ts+++ b/apps/server/src/orchestration-v2/ProviderSessionManager.ts@@ -50,6 +50,7 @@ import * as CommandOutputHub from "./CommandOutputHub.ts";import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";import * as ProviderEventIngestor from "./ProviderEventIngestor.ts";import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";+import { makeProviderFailure } from "@t3tools/provider-core/server/failure";import * as ProviderAdapterRegistry from "./ProviderAdapterRegistry.ts";import * as ProjectionStore from "./ProjectionStore.ts";@@ -1987,10 +1988,16 @@ export const layerWithOptions = (cause,});yield* Ref.set(entry.eventSubscribers, new Map());+ // lastError is the thread banner, so it gets the same bounded+ // message as a failed turn; the raw cause survives only in the log.+ yield* Effect.logWarning("orchestration-v2.provider-session-runtime-failed", {+ providerSessionId: entry.runtime.providerSessionId,+ cause,+ });yield* releaseEntry({providerSessionId: entry.runtime.providerSessionId,reason: "runtime_error",- detail: Cause.pretty(cause),+ detail: makeProviderFailure({ cause }).message,}).pipe(logReleaseFailure(entry.runtime.providerSessionId));}),),