Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 66 additions & 2 deletions apps/server/src/textGeneration/ClaudeTextGeneration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
body: "",
},
}),
argsMustContain: '--settings {"alwaysThinkingEnabled":false}',
argsMustContain: '--settings {"verbose":false,"alwaysThinkingEnabled":false}',
argsMustNotContain: "--effort",
},
(textGeneration) =>
Expand Down Expand Up @@ -266,7 +266,7 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
body: "Body",
},
}),
argsMustContain: '--effort max --settings {"fastMode":true}',
argsMustContain: '--effort max --settings {"verbose":false,"fastMode":true}',
},
(textGeneration) =>
Effect.gen(function* () {
Expand Down Expand Up @@ -377,4 +377,68 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
}),
),
);

it.effect("pins verbose output off even without other Claude settings", () =>
withFakeClaudeEnv(
{
output: JSON.stringify({
structured_output: {
title: "Reconnect failures after restart",
},
}),
argsMustContain: '--settings {"verbose":false}',
},
(textGeneration) =>
Effect.gen(function* () {
const generated = yield* textGeneration.generateThreadTitle({
cwd: process.cwd(),
message: "Please investigate reconnect failures after restarting the session.",
modelSelection: {
instanceId: ProviderInstanceId.make("claudeAgent"),
model: "claude-sonnet-4-6",
},
});

expect(generated.title).toBe(sanitizeThreadTitle("Reconnect failures after restart"));
}),
),
);

// Guards the assumption behind `verbose: false`: should the CLI ever stream
// events despite the pinned setting, this fails loudly instead of silently.
it.effect("fails when the CLI streams events instead of the envelope", () =>
withFakeClaudeEnv(
{
output: JSON.stringify([
{ type: "system", subtype: "init", session_id: "abc" },
{ type: "assistant", message: { role: "assistant", content: [] } },
{ type: "user", message: { role: "user", content: [] } },
{ type: "rate_limit_event", rate_limit: { status: "allowed" } },
{
type: "result",
subtype: "success",
is_error: false,
result: '{"title":"Reconnect failures after restart"}',
structured_output: { title: "Reconnect failures after restart" },
},
]),
},
(textGeneration) =>
Effect.gen(function* () {
const error = yield* Effect.flip(
textGeneration.generateThreadTitle({
cwd: process.cwd(),
message: "Name this thread.",
modelSelection: {
instanceId: ProviderInstanceId.make("claudeAgent"),
model: "claude-sonnet-4-6",
},
}),
);

expect(error._tag).toBe("TextGenerationError");
expect(error.detail).toContain("unexpected output format");
}),
),
);
});
3 changes: 3 additions & 0 deletions apps/server/src/textGeneration/ClaudeTextGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ export const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(fu
const fastMode =
fastModeDescriptor?.type === "boolean" ? fastModeDescriptor.currentValue : undefined;
const settings = {
// Pinned: a user-level `verbose` makes the CLI print a stream-event array
// instead of the single JSON envelope we parse.
verbose: false,
...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}),
...(fastMode ? { fastMode: true } : {}),
...(ultracode ? { ultracode: true } : {}),
Expand Down
Loading