Skip to content

Commit c44e43f

Browse files
authored
Merge pull request #2453 from jeongjin0/fix/wait-yield-time-ms-underscore
fix(tools): coerce wait.yield_time_ms as an integral float
2 parents d5018f0 + 95a3f67 commit c44e43f

2 files changed

Lines changed: 41 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: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,34 @@ 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 priorityOnly = '{"priority":2.0}';
345+
expect(coerceIntegerToolArguments(
346+
priorityOnly,
347+
schema,
348+
"wait",
349+
)).toBe(priorityOnly);
350+
const other = {
332351
type: "object",
333352
properties: { yield_time_ms: { type: "number" }, priority: { type: "number" } },
334353
};
335354
const raw = '{"yield_time_ms":60000.0,"priority":2.0}';
336-
expect(coerceIntegerToolArguments(raw, others, "wait")).toBe(raw);
355+
expect(coerceIntegerToolArguments(raw, other, "other_tool")).toBe(raw);
337356
});
338357

339358
test("the namespaced wait_agent call is repaired through the real bridge", async () => {
@@ -367,7 +386,7 @@ describe("native u64 fields advertised as number (#2316)", () => {
367386
const CODEX_DESKTOP_WAIT_SCHEMA = {
368387
type: "object",
369388
properties: {
370-
"yield-time_ms": { type: "number" },
389+
"yield_time_ms": { type: "number" },
371390
max_tokens: { type: "number" },
372391
},
373392
};
@@ -384,26 +403,26 @@ const WAIT_SCOPE_NAMESPACE_MAP = new Map([
384403

385404
const WAIT_SCOPE_EVENTS: AdapterEvent[] = [
386405
{ type: "tool_call_start", id: "call_wait", name: "wait" },
387-
{ 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}' },
388407
{ type: "tool_call_end", id: "call_wait" },
389408
{ type: "tool_call_start", id: "call_fractional", name: "wait" },
390-
{ type: "tool_call_delta", arguments: '{"yield-time_ms":1.5,"max_tokens":1.5}' },
409+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":1.5,"max_tokens":1.5}' },
391410
{ type: "tool_call_end", id: "call_fractional" },
392411
{ 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}' },
412+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
394413
{ type: "tool_call_end", id: "call_other" },
395414
{ 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}' },
415+
{ type: "tool_call_delta", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
397416
{ type: "tool_call_end", id: "call_namespaced" },
398417
{ type: "done" },
399418
];
400419

401-
describe("Codex Desktop wait native integers (#2443)", () => {
420+
describe("Codex Desktop wait native integers (#2443 / #2451)", () => {
402421
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}' },
422+
{ name: "wait", namespace: undefined, arguments: '{"yield_time_ms":120000,"max_tokens":8000}' },
423+
{ name: "wait", namespace: undefined, arguments: '{"yield_time_ms":1.5,"max_tokens":1.5}' },
424+
{ name: "other_tool", namespace: undefined, arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
425+
{ name: "wait", namespace: "cursor", arguments: '{"yield_time_ms":120000.0,"max_tokens":8000.0}' },
407426
];
408427

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

0 commit comments

Comments
 (0)