Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): T3 tools work again after a thread switches back to a reused provider session #17096

Closedjieyuexing(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/17096/headopened View on GitHub

Showing 2 changed files with 82 additions and 15 deletions.

x
0 of 2 viewed, 2 left
55 additions and 0 deletionsapps/server/src/orchestration-v2/ProviderSessionManager.test.tsModified
View file
@@ -2406,6 +2406,61 @@
+it.effect(
+ "ProviderSessionManagerV2 takes the thread's MCP credential back when a run returns to a still-attached session",
+ () =>
+ Effect.gen(function* () {
+ const state = yield* Ref.make(emptyState);
+ const effect = Effect.gen(function* () {
+ const eventSink = yield* EventSink.EventSinkV2;
+ const idAllocator = yield* IdAllocator.IdAllocatorV2;
+ const manager = yield* ProviderSessionManager.ProviderSessionManagerV2;
+ const registry = yield* McpSessionRegistry.McpSessionRegistry;
+ const now = yield* DateTime.now;
+ const threadId = ThreadId.make("thread-provider-session-manager-returning-provider");
+ const providerSessionId = yield* idAllocator.allocate.providerSession({
+ providerInstanceId: modelSelection.instanceId,
+ threadId,
+ });
+ const tokenOf = (config: McpProviderSession.McpProviderSessionConfig | undefined) =>
+ config?.authorizationHeader.replace(/^Bearer\s+/, "") ?? "";
+​
+ yield* eventSink.write({
+ events: [yield* makeThreadCreatedEvent({ idAllocator, threadId, now })],
+ });
+ yield* manager.open({ threadId, providerSessionId, modelSelection, runtimePolicy });
+​
+ // The thread switches to another provider, whose attach replaces the
+ // thread's credential while this session stays attached.