Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): Pi turns start while an extension run is streaming #15444

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

Showing 11 changed files with 36 additions and 1 deletion (loading 8).

x
0 of 11 viewed, 11 left
31 additions and 0 deletionsapps/server/src/orchestration-v2/Adapters/PiAdapterV2.test.tsModified
View file
@@ -1597,6 +1597,37 @@
}).pipe(Effect.scoped, Effect.provide(testLayer)),
+ it.effect("starts a turn while an extension run is already streaming", () =>
+ Effect.gen(function* () {
+ const fake = yield* makeFakePi;
+ const { runtime, takeEvent } = yield* openRuntime(fake);
+ const providerThread = yield* runtime.ensureThread({
+ threadId: THREAD_ID,
+ modelSelection: modelSelection("default"),
+ runtimePolicy,
+ });
+ yield* startTurn(runtime, providerThread);
+ const prompt = yield* fake.takeRequest("prompt");
+ // An extension continuation resumed with the session and is streaming.
+ // Pi rejects a prompt without streamingBehavior while it streams.
+ yield* fake.emit({ type: "agent_start" });
+ yield* fake.emit(
+ prompt["streamingBehavior"] === undefined
+ ? {
+ type: "response",
+ command: "prompt",
+ success: false,
+ error:
+ "Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.",
+ }
+ : { type: "response", command: "prompt", success: true },
+ );
+ yield* fake.emit({ type: "agent_settled" });