@@ -3909,42 +3909,6 @@ describe("ClaudeAdapterV2 background wake turns", () => {
39093909 }).pipe(Effect.provide(modelTestLayer)),
39103910 );
39113911
3912- it.effect("does not switch the model while draining a native background continuation", () =>
3913- Effect.gen(function* () {
3914- const harness = yield* makeWakeHarness;
3915- const first = yield* makeModelTurn(harness, "fallback-background", {
3916- text: "Run a background task.",
3917- });
3918- yield* harness.runtime.startTurn(first);
3919- yield* harness.offerAndWait(fallbackFrame());
3920- yield* Queue.take(harness.systemNoticeReceipts);
3921- yield* harness.offerAndWait(wakeTaskStarted);
3922- yield* harness.offerAndWait(turnOneResult);
3923- yield* Queue.take(harness.terminalReceipts);
3924- yield* harness.offerAndWait(wakeNotification);
3925- yield* harness.offerAndWait(wakeTurnInit);
3926- yield* Queue.take(harness.continuationReceipts);
3927- const latest = latestProviderThreadUpdate(harness.events);
3928- yield* harness.runtime.startTurn(
3929- nextModelTurn(first, "fallback-background-continuation", {
3930- providerThread: latest.providerThread,
3931- message: { ...first.message, createdBy: "agent", creationSource: "provider" },
3932- }),
3933- );
3934- yield* harness.offerAndWait(
3935- makeAssistantTextFrame({
3936- uuid: "fallback-wake-answer",
3937- text: WAKE_ASSISTANT_TEXT,
3938- model: "claude-opus-5",
3939- }),
3940- );
3941- yield* harness.offerAndWait(wakeResult);
3942- yield* Queue.take(harness.terminalReceipts);
3943- assert.isEmpty(harness.liveSelectionChanges);
3944- assert.lengthOf(harness.offeredMessages, 1);
3945- }).pipe(Effect.provide(modelTestLayer)),
3946- );
3947-
39483912 it.effect.each([false, true])(
39493913 "replays a model downgrade before continuation attachment with fallback before wake init %s",
39503914 (beforeWakeInit) =>
@@ -4043,89 +4007,6 @@ describe("ClaudeAdapterV2 background wake turns", () => {
40434007 }).pipe(Effect.provide(modelTestLayer)),
40444008 );
40454009
4046- it.effect.each([false, true])(
4047- "preserves a manual gateway alias after a downgrade with resumed session %s",
4048- (resumed) =>
4049- Effect.gen(function* () {
4050- const harness = yield* makeWakeHarness;
4051- const first = yield* makeModelTurn(harness, "fallback-gateway-first");
4052- let providerThread: OrchestrationV2ProviderThread = {
4053- ...harness.providerThread,
4054- nativeMetadata: {
4055- modelSelection: { ...selected, model: "claude-opus-5" },
4056- },
4057- };
4058- if (!resumed) {
4059- yield* harness.runtime.startTurn(first);
4060- yield* harness.offerAndWait(fallbackFrame());
4061- yield* Queue.take(harness.systemNoticeReceipts);
4062- yield* harness.offerAndWait(
4063- makeResultFrame({ uuid: "fallback-gateway-first-result", result: "Done." }),
4064- );
4065- yield* Queue.take(harness.terminalReceipts);
4066- const latest = latestProviderThreadUpdate(harness.events);
4067- providerThread = latest.providerThread;
4068- }
4069- const gateway = { ...selected, model: "gateway-opus" };
4070- const next = nextModelTurn(first, "fallback-gateway-next", {
4071- appThread: { ...first.appThread, modelSelection: gateway },
4072- providerThread,
4073- modelSelection: gateway,
4074- nativeThreadHasTurns: true,
4075- });
4076- yield* harness.runtime.startTurn(next);
4077- assert.deepEqual(harness.liveSelectionChanges[0], { model: gateway.model });
4078- yield* harness.offerAndWait(
4079- makeAssistantTextFrame({
4080- uuid: "fallback-gateway-answer",
4081- text: "Done.",
4082- model: selected.model,
4083- }),
4084- );
4085- yield* harness.offerAndWait(
4086- makeResultFrame({ uuid: "fallback-gateway-result", result: "Done." }),
4087- );
4088- yield* Queue.take(harness.terminalReceipts);
4089- const selectionChanges = harness.events.flatMap((event) =>
4090- event.type === "provider_thread.updated" && event.modelSelectionChange !== undefined
4091- ? [event.modelSelectionChange]
4092- : [],
4093- );
4094- assert.deepEqual(
4095- selectionChanges,
4096- resumed ? [] : [{ expected: selected, next: { ...selected, model: "claude-opus-5" } }],
4097- );
4098- const completed = latestProviderThreadUpdate(harness.events);
4099- assert.deepEqual(completed.providerThread.nativeMetadata?.modelSelection, gateway);
4100- const changesBeforeNext = harness.liveSelectionChanges.length;
4101- yield* harness.runtime.startTurn(
4102- nextModelTurn(next, "fallback-gateway-third", {
4103- providerThread: completed.providerThread,
4104- }),
4105- );
4106- assert.lengthOf(harness.liveSelectionChanges, changesBeforeNext);
4107- }).pipe(Effect.provide(modelTestLayer)),
4108- );
4109-
4110- it.effect("does not mistake a gateway's canonical model name for a downgrade", () =>
4111- Effect.gen(function* () {
4112- const harness = yield* makeWakeHarness;
4113- yield* harness.runtime.startTurn(
4114- yield* makeModelTurn(harness, "fallback-gateway", {
4115- modelSelection: { ...selected, model: "gateway-opus" },
4116- }),
4117- );
4118- yield* harness.offerAndWait(
4119- makeAssistantTextFrame({ uuid: "gateway-answer", text: "Done.", model: selected.model }),
4120- );
4121- yield* harness.offerAndWait(makeResultFrame({ uuid: "gateway-result", result: "Done." }));
4122- yield* Queue.take(harness.terminalReceipts);
4123- const latest = latestProviderThreadUpdate(harness.events);
4124- assert.isUndefined(latest.providerThread.nativeMetadata?.modelSelection);
4125- assert.isEmpty(harness.liveSelectionChanges);
4126- }).pipe(Effect.provide(modelTestLayer)),
4127- );
4128-
41294010 it.effect.each([
41304011 { selection: selected, apiModelId: selected.model },
41314012 {
0 commit comments