Skip to content

Commit e46bee5

Browse files
jieyuexingclaude
andcommitted
fix(contracts): a null model selection options value is treated as omitted
MCP tools advertise ModelSelection.options as an unconstrained value, so clients that fill optional fields with null send `options: null`. The decode transform forwarded that null to the wire schema, which only accepts an array or a legacy object, and the call failed with "Expected array | object". Treat null like an omitted options field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d01b92c commit e46bee5

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/contracts/src/modelSelection.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ it.effect("ModelSelection prefers explicit instanceId over legacy provider", ()
3232
}),
3333
);
3434

35+
it.effect("ModelSelection treats null options as omitted", () =>
36+
Effect.gen(function* () {
37+
const parsed = yield* decodeModelSelection({
38+
instanceId: "codex",
39+
model: "gpt-5",
40+
options: null,
41+
});
42+
assert.deepStrictEqual(parsed, {
43+
instanceId: ProviderInstanceId.make("codex"),
44+
model: "gpt-5",
45+
});
46+
}),
47+
);
48+
3549
it.effect(
3650
"ModelSelection decodes unknown driver kinds via legacy provider (rollback / fork invariant)",
3751
() =>

‎packages/contracts/src/modelSelection.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const ModelSelection = ModelSelectionSource.pipe(
3434
instanceId: instanceIdSource,
3535
model: raw.model,
3636
};
37-
if (raw.options !== undefined) base.options = raw.options;
37+
if (raw.options !== undefined && raw.options !== null) base.options = raw.options;
3838
return Effect.succeed(base as typeof ModelSelectionWire.Encoded);
3939
},
4040
encode: (value) => {

0 commit comments

Comments
 (0)