@@ -5759,7 +5759,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57595759 "process cwd",
57605760 "launch inline",
57615761 "launch file",
5762- "stalled settings",
5762+ "stalled lookup",
5763+ "reused endpoint",
5764+ "reused model",
57635765 ])("uses the matching proxy reset from %s when Claude omits a reset time", (source) =>
57645766 Effect.gen(function* () {
57655767 const fs = yield* FileSystem.FileSystem;
@@ -5797,15 +5799,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57975799 const launchSettings = JSON.stringify({ env: { ANTHROPIC_BASE_URL: "https://hub.test/v1" } });
57985800 if (source === "launch file")
57995801 yield* fs.writeFileString(path.join(cwd, "launch.json"), launchSettings);
5800- const readStarted = yield* Deferred.make<void>();
5801- let stallSettingsRead = false;
5802- const stalledFileSystem = {
5803- ...fs,
5804- readFileString: (filePath: string) =>
5805- stallSettingsRead && filePath === path.join(configDir, "settings.json")
5806- ? Deferred.succeed(readStarted, undefined).pipe(Effect.andThen(Effect.never))
5807- : fs.readFileString(filePath),
5808- };
5802+ const lookupStarted = yield* Deferred.make<void>();
58095803 const harness = yield* makeWakeHarnessWithOptions({
58105804 settings: {
58115805 ...DEFAULT_CLAUDE_SETTINGS,
@@ -5819,11 +5813,25 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58195813 environment: {
58205814 CLAUDE_CONFIG_DIR: configDir,
58215815 ANTHROPIC_BASE_URL:
5822- source === "environment" ? "https://hub.test/v1" : "https://wrong.test",
5816+ source === "environment" || source.startsWith("reused") || source === "stalled lookup"
5817+ ? "https://hub.test/v1"
5818+ : "https://wrong.test",
58235819 },
58245820 }).pipe(
58255821 Effect.provideService(HostProcess.WorkingDirectory, cwd),
5826- Effect.provideService(FileSystem.FileSystem, stalledFileSystem),
5822+ Effect.provide(
5823+ Layer.mock(UsageLimitSources.UsageLimitSources)({
5824+ resolveResetAt: (input) => {
5825+ assert.equal(input.endpoint, "https://hub.test/v1");
5826+ assert.equal(input.model, CLAUDE_TEST_MODEL_SELECTION.model);
5827+ if (source === "stalled lookup")
5828+ return Deferred.succeed(lookupStarted, undefined).pipe(
5829+ Effect.andThen(Effect.never),
5830+ );
5831+ return Effect.succeed("2099-01-01T02:00:00.000Z");
5832+ },
5833+ }),
5834+ ),
58275835 );
58285836 const now = yield* DateTime.now;
58295837 yield* harness.runtime.startTurn(
@@ -5836,11 +5844,34 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58365844 attachments: [],
58375845 runtimePolicy: {
58385846 ...CLAUDE_TEST_RUNTIME_POLICY,
5839- cwd: source === "process cwd" || source === "stalled settings " ? null : cwd,
5847+ cwd: source === "process cwd" || source === "stalled lookup " ? null : cwd,
58405848 },
58415849 }),
58425850 );
5843- stallSettingsRead = source === "stalled settings";
5851+ if (source.startsWith("reused")) {
5852+ yield* Queue.offer(harness.sdkMessages, turnOneResult);
5853+ assert.equal((yield* Queue.take(harness.terminalReceipts)).status, "completed");
5854+ if (source === "reused endpoint")
5855+ yield* fs.writeFileString(
5856+ path.join(configDir, "settings.json"),
5857+ JSON.stringify({ env: { ANTHROPIC_BASE_URL: "https://wrong.test" } }),
5858+ );
5859+ yield* harness.runtime.startTurn(
5860+ makeClaudeTestTurnInput({
5861+ threadId: harness.threadId,
5862+ providerThread: harness.providerThread,
5863+ now,
5864+ attemptId: RunAttemptId.make("attempt-proxy-continuation"),
5865+ providerTurnOrdinal: 2,
5866+ messageCreatedBy: "agent",
5867+ messageCreationSource: "provider",
5868+ modelSelection: CLAUDE_TEST_RESTART_MODEL_SELECTION,
5869+ runtimePolicy: { ...CLAUDE_TEST_RUNTIME_POLICY, cwd: configDir },
5870+ text: "Background task completed.",
5871+ attachments: [],
5872+ }),
5873+ );
5874+ }
58445875 yield* Queue.offerAll(harness.sdkMessages, [
58455876 makeAssistantErrorFrame({
58465877 uuid: "00000000-0000-4000-8000-000000000652",
@@ -5854,8 +5885,8 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58545885 apiErrorStatus: 429,
58555886 }),
58565887 ]);
5857- if (source === "stalled settings ") {
5858- yield* Deferred.await(readStarted );
5888+ if (source === "stalled lookup ") {
5889+ yield* Deferred.await(lookupStarted );
58595890 yield* TestClock.adjust("15 seconds");
58605891 }
58615892 const terminal = yield* Queue.take(harness.terminalReceipts);
@@ -5864,22 +5895,9 @@ describe("ClaudeAdapterV2 background wake turns", () => {
58645895 assert.equal(terminal.failure.class, "usage_limit");
58655896 assert.equal(
58665897 terminal.failure.resetAt,
5867- source === "stalled settings " ? null : "2099-01-01T02:00:00.000Z",
5898+ source === "stalled lookup " ? null : "2099-01-01T02:00:00.000Z",
58685899 );
5869- }).pipe(
5870- Effect.provide([
5871- IdAllocator.layer,
5872- McpProviderSessions.layer,
5873- NodeServices.layer,
5874- Layer.mock(UsageLimitSources.UsageLimitSources)({
5875- resolveResetAt: (input) => {
5876- assert.equal(input.endpoint, "https://hub.test/v1");
5877- assert.isNotEmpty(input.model);
5878- return Effect.succeed("2099-01-01T02:00:00.000Z");
5879- },
5880- }),
5881- ]),
5882- ),
5900+ }).pipe(Effect.provide([IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer])),
58835901 );
58845902
58855903 it.effect.each([
0 commit comments