From 777d6a33ea7267141216730bae99f2553b3b912f Mon Sep 17 00:00:00 2001 From: Hashem Khalifa Date: Fri, 20 Nov 2026 15:04:24 +0100 Subject: [PATCH] fix(server): Claude memory runs return structured output again Isolated text generation (memory extraction, fact checks, memory curation, conversation summaries, model evaluations) passed `--disallowedTools *`. Claude CLI 2.1.329 then exits 0 without a `structured_output` key, so every isolated run failed. `--tools ""` already removes every tool, so the flag added no isolation. Drop it and assert it stays out. Co-Authored-By: Claude Opus 5.5 --- .../textGeneration/ClaudeTextGeneration.test.ts | 15 +++++++++------ .../src/textGeneration/ClaudeTextGeneration.ts | 4 +++- .../testing/ClaudeTextGeneration.fixture.mjs | 7 +++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apps/server/src/textGeneration/ClaudeTextGeneration.test.ts b/apps/server/src/textGeneration/ClaudeTextGeneration.test.ts index 824cff522d4c9..488cacea3a47e 100644 --- a/apps/server/src/textGeneration/ClaudeTextGeneration.test.ts +++ b/apps/server/src/textGeneration/ClaudeTextGeneration.test.ts @@ -233,8 +233,9 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => { Effect.gen(function* () { const isolation = { cwdMustNotBe: process.cwd(), - argsMustContain: "--safe-mode --disallowedTools * --setting-sources", - argsMustNotContain: "--bare", + argsMustContain: "--safe-mode --setting-sources", + // `--disallowedTools *` also blocks the tool Claude uses to return structured_output. + argsMustNotContain: "--bare\n--disallowedTools", }; const modelSelection = { instanceId: ProviderInstanceId.make("claudeAgent"), @@ -293,8 +294,9 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => { { output: JSON.stringify({ structured_output: { statements: [] } }), cwdMustNotBe: process.cwd(), - argsMustContain: "--safe-mode --disallowedTools * --setting-sources", - argsMustNotContain: "--bare", + argsMustContain: "--safe-mode --setting-sources", + // `--disallowedTools *` also blocks the tool Claude uses to return structured_output. + argsMustNotContain: "--bare\n--disallowedTools", }, (textGeneration) => textGeneration.generateConversationSummary({ @@ -329,8 +331,9 @@ it.layer(layerClaudeTextGenerationTest)("ClaudeTextGeneration", (it) => { }, }), cwdMustNotBe: process.cwd(), - argsMustContain: "--safe-mode --disallowedTools * --setting-sources", - argsMustNotContain: "--bare", + argsMustContain: "--safe-mode --setting-sources", + // `--disallowedTools *` also blocks the tool Claude uses to return structured_output. + argsMustNotContain: "--bare\n--disallowedTools", }, (textGeneration) => textGeneration.generateModelEvaluation({ diff --git a/apps/server/src/textGeneration/ClaudeTextGeneration.ts b/apps/server/src/textGeneration/ClaudeTextGeneration.ts index 6bc7c31b3284d..081cae075f5f9 100644 --- a/apps/server/src/textGeneration/ClaudeTextGeneration.ts +++ b/apps/server/src/textGeneration/ClaudeTextGeneration.ts @@ -334,7 +334,9 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu ...(investigate ? ["--setting-sources", "user"] : []), "--disable-slash-commands", // Safe mode isolates customizations while retaining subscription authentication. - ...(isolated ? ["--safe-mode", "--disallowedTools", "*", "--setting-sources", ""] : []), + // `--tools ""` already removes every tool; `--disallowedTools *` would also block the + // internal tool that returns `structured_output`, so every isolated run would fail. + ...(isolated ? ["--safe-mode", "--setting-sources", ""] : []), ...(noSessionPersistence ? [NO_SESSION_PERSISTENCE] : []), // managed-mcp.json already isolates servers and makes Claude reject this flag. ...(managedMcpConfig ? [] : ["--strict-mcp-config"]), diff --git a/apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs b/apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs index 645f579e48195..d6da5e8f1e3ad 100644 --- a/apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs +++ b/apps/server/src/textGeneration/testing/ClaudeTextGeneration.fixture.mjs @@ -58,8 +58,11 @@ if (argsMustContain && !args.includes(argsMustContain)) { fail("args missing expected content", 2); } -const argsMustNotContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN; -if (argsMustNotContain && args.includes(argsMustNotContain)) { +// One forbidden fragment per line. +const argsMustNotContain = (process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN ?? "") + .split("\n") + .filter(Boolean); +if (argsMustNotContain.some((fragment) => args.includes(fragment))) { fail("args contained forbidden content", 3); }