Skip to content

Commit beb68c4

Browse files
committed
Fix: allow clearing cached provider model options and fix mock agent test assertion
- mergeThreadModelOptions: use 'key in incoming' check instead of nullish coalescing so that explicitly present-but-undefined provider keys clear previously cached values instead of silently inheriting stale options. - sendTurnForThread: delete threadModelOptions cache entry when merge produces undefined, so cleared options don't persist. - AcpJsonRpcConnection test: use toMatchObject instead of toEqual for session/new result, since mock agent returns extra 'modes' field.
1 parent 12f825a commit beb68c4

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

apps/server/src/orchestration/Layers/ProviderCommandReactor.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,17 @@ function mergeThreadModelOptions(
5050
cached: ProviderModelOptions | undefined,
5151
incoming: ProviderModelOptions | undefined,
5252
): ProviderModelOptions | undefined {
53-
if (!cached && !incoming) {
54-
return undefined;
53+
if (incoming === undefined) return cached;
54+
if (cached === undefined) return incoming;
55+
56+
const providerKeys = ["codex", "claudeAgent", "cursor"] as const;
57+
const next: Record<string, unknown> = {};
58+
for (const key of providerKeys) {
59+
const value = key in incoming ? incoming[key] : cached[key];
60+
if (value !== undefined) {
61+
next[key] = value;
62+
}
5563
}
56-
const next = {
57-
...(incoming?.codex !== undefined || cached?.codex !== undefined
58-
? { codex: incoming?.codex ?? cached?.codex }
59-
: {}),
60-
...(incoming?.claudeAgent !== undefined || cached?.claudeAgent !== undefined
61-
? { claudeAgent: incoming?.claudeAgent ?? cached?.claudeAgent }
62-
: {}),
63-
...(incoming?.cursor !== undefined || cached?.cursor !== undefined
64-
? { cursor: incoming?.cursor ?? cached?.cursor }
65-
: {}),
66-
} satisfies Partial<ProviderModelOptions>;
6764
return Object.keys(next).length > 0 ? (next as ProviderModelOptions) : undefined;
6865
}
6966

@@ -405,8 +402,12 @@ const make = Effect.gen(function* () {
405402
threadModelOptions.get(input.threadId),
406403
input.modelOptions,
407404
);
408-
if (mergedModelOptions !== undefined) {
409-
threadModelOptions.set(input.threadId, mergedModelOptions);
405+
if (input.modelOptions !== undefined) {
406+
if (mergedModelOptions !== undefined) {
407+
threadModelOptions.set(input.threadId, mergedModelOptions);
408+
} else {
409+
threadModelOptions.delete(input.threadId);
410+
}
410411
}
411412
const normalizedInput = toNonEmptyProviderInput(input.messageText);
412413
const normalizedAttachments = input.attachments ?? [];

apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("AcpJsonRpcConnection", () => {
3232
cwd: process.cwd(),
3333
mcpServers: [],
3434
});
35-
expect(newResult).toEqual({ sessionId: "mock-session-1" });
35+
expect(newResult).toMatchObject({ sessionId: "mock-session-1" });
3636

3737
const promptResult = yield* conn.request("session/prompt", {
3838
sessionId: "mock-session-1",

0 commit comments

Comments
 (0)