Skip to content

Commit dfb62f9

Browse files
committed
fix(tools): coerce wait.yield_time_ms as an integral float
#2448 scoped the wait repair correctly but allowlisted the hyphenated yield-time_ms name. Live Grok 4.6 Codex Desktop calls still emit yield_time_ms: 20000.0 and Codex rejects them as u64 before wait runs. Keep the repair wait-scoped so namespaced Cursor calls stay untouched.
1 parent 9cebfc6 commit dfb62f9

2 files changed

Lines changed: 35 additions & 18 deletions

File tree

‎src/lib/tool-argument-integers.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ function declaresString(schema: SchemaNode): boolean {
7777
// against it. It gets its own change when it gets its own reproduction.
7878
const U64_NUMBER_FIELDS = new Set(["timeout_ms"]);
7979

80-
// Issue #2443: Codex Desktop's bare `wait` tool has the same schema/runtime split
81-
// for `yield-time_ms` and `max_tokens`. Scope these names to that bare tool so a
80+
// Issue #2443 / #2451: Codex Desktop's bare `wait` tool has the same schema/runtime
81+
// split for `yield_time_ms` and `max_tokens`. Scope these names to that bare tool so a
8282
// third-party or namespaced tool can still use fractional values legitimately.
83+
// #2448 allowlisted the hyphenated `yield-time_ms`; live Grok 4.6 calls and the
84+
// advertised wait schema both use the underscore form, so that name is the one
85+
// with a captured u64 rejection. Cursor still uses the same underscore name on a
86+
// namespaced tool; the wait-only map keeps that path byte-identical.
8387
const U64_NUMBER_FIELDS_BY_TOOL = new Map<string, ReadonlySet<string>>([
84-
["wait", new Set(["yield-time_ms", "max_tokens"])],
88+
["wait", new Set(["yield_time_ms", "max_tokens"])],
8589
]);
8690

8791
/** True when the node accepts a JSON number (`integer` or `number`), so a numeric

‎tests/tool-argument-integers.test.ts‎

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,28 @@ describe("native u64 fields advertised as number (#2316)", () => {
325325
.toBe('{"timeout_ms":"120000"}');
326326
});
327327

328-
test("Cursor's sibling field stays unchanged even with wait identity", () => {
329-
// Cursor uses yield_time_ms (underscore), not wait's yield-time_ms (hyphen).
330-
// Keep this explicit scope proof from #2316: field names are never broadened globally.
331-
const others = {
328+
test("bare wait repairs yield_time_ms and leaves unrelated number fields alone", () => {
329+
// Live Codex Desktop wait uses the underscore form (#2451). Wait identity
330+
// repairs that field and max_tokens, but never a generic number field.
331+
const schema = {
332+
type: "object",
333+
properties: {
334+
yield_time_ms: { type: "number" },
335+
max_tokens: { type: "number" },
336+
priority: { type: "number" },
337+
},
338+
};
339+
expect(coerceIntegerToolArguments(
340+
'{"yield_time_ms":20000.0,"max_tokens":5000.0,"priority":2.0}',
341+
schema,
342+
"wait",
343+
)).toBe('{"yield_time_ms":20000,"max_tokens":5000,"priority":2}');
344+
const other = {
332345
type: "object",
333346
properties: { yield_time_ms: { type: "number" }, priority: { type: "number" } },
334347
};
335348
const raw = '{"yield_time_ms":60000.0,"priority":2.0}';
336-
expect(coerceIntegerToolArguments(raw, others, "wait")).toBe(raw);
349+
expect(coerceIntegerToolArguments(raw, other, "other_tool")).toBe(raw);
337350
});
338351

339352
test("the namespaced wait_agent call is repaired through the real bridge", async () => {
@@ -367,7 +380,7 @@ describe("native u64 fields advertised as number (#2316)", () => {
367380
const CODEX_DESKTOP_WAIT_SCHEMA = {
368381
type: "object",
369382
properties: {
370-
"yield-time_ms": { type: "number" },
383+
"yield_time_ms": { type: "number" },
371384
max_tokens: { type: "number" },
372385
},
373386
};
@@ -384,26 +397,26 @@ const WAIT_SCOPE_NAMESPACE_MAP = new Map([
384397

385398
const WAIT_SCOPE_EVENTS: AdapterEvent[] = [
386399
{ type: "tool_call_start", id: "call_wait", name: "wait" },
387-
{ type: "tool_call_delta", arguments: '{"yield-time_ms":120000.0,"max_tokens":8000.0}' },
400+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
388401
{ type: "tool_call_end", id: "call_wait" },
389402
{ type: "tool_call_start", id: "call_fractional", name: "wait" },
390-
{ type: "tool_call_delta", arguments: '{"yield-time_ms":1.5,"max_tokens":1.5}' },
403+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":1.5,"max_tokens":1.5}' },
391404
{ type: "tool_call_end", id: "call_fractional" },
392405
{ type: "tool_call_start", id: "call_other", name: "other_tool" },
393-
{ type: "tool_call_delta", arguments: '{"yield-time_ms":120000.0,"max_tokens":8000.0}' },
406+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
394407
{ type: "tool_call_end", id: "call_other" },
395408
{ type: "tool_call_start", id: "call_namespaced", name: "cursor_wait" },
396-
{ type: "tool_call_delta", arguments: '{"yield-time_ms":120000.0,"max_tokens":8000.0}' },
409+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
397410
{ type: "tool_call_end", id: "call_namespaced" },
398411
{ type: "done" },
399412
];
400413

401-
describe("Codex Desktop wait native integers (#2443)", () => {
414+
describe("Codex Desktop wait native integers (#2443 / #2451)", () => {
402415
const expectedCalls = [
403-
{ name: "wait", namespace: undefined, arguments: '{"yield-time_ms":120000,"max_tokens":8000}' },
404-
{ name: "wait", namespace: undefined, arguments: '{"yield-time_ms":1.5,"max_tokens":1.5}' },
405-
{ name: "other_tool", namespace: undefined, arguments: '{"yield-time_ms":120000.0,"max_tokens":8000.0}' },
406-
{ name: "wait", namespace: "cursor", arguments: '{"yield-time_ms":120000.0,"max_tokens":8000.0}' },
416+
{ name: "wait", namespace: undefined, arguments: '{"yield_time_ms":120000,"max_tokens":8000}' },
417+
{ name: "wait", namespace: undefined, arguments: '{"yield_time_ms":1.5,"max_tokens":1.5}' },
418+
{ name: "other_tool", namespace: undefined, arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
419+
{ name: "wait", namespace: "cursor", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
407420
];
408421

409422
test("streaming bridge scopes the repair to the bare wait tool", async () => {

0 commit comments

Comments
 (0)