Skip to content

fix(tools): repair integral float arguments for native integer fields - #2360

Closed
chilung-cgu wants to merge 1 commit into
lidge-jun:devfrom
chilung-cgu:fix/issue-2316-wait-agent-timeout-ms-integer-repair
Closed

fix(tools): repair integral float arguments for native integer fields#2360
chilung-cgu wants to merge 1 commit into
lidge-jun:devfrom
chilung-cgu:fix/issue-2316-wait-agent-timeout-ms-integer-repair

Conversation

@chilung-cgu

@chilung-cgu chilung-cgu commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Closes #2316

Summary

  • Repairs integral floats (e.g. 120000.0) emitted by providers like Grok for Codex native integer fields (e.g. timeout_ms, yield_time_ms, session_id, max_tokens, etc.) even when the tool parameter schema declares type: "number" or type: ["number", "null"].
  • Resolves schema lookup across namespaced wire names (e.g. multi_agent_v1__wait_agent, collaboration__wait_agent) and bare names (wait_agent) so tool argument repair reliably finds the declared schema in both streaming and non-streaming responses.
  • Preserves honest failure for true fractional numbers (timeout_ms: 1.5) and leaves non-integer number fields (e.g. temperature: 1.0) untouched.

Verification

  • bun test tests/tool-argument-integers.test.ts (30 pass, 0 fail, covering integral floats, aliases, non-integral preservation, and streaming/non-streaming bridges)
  • bun test tests/core-lab-boundary.test.ts (13 pass, 0 fail)
  • bun test tests/bridge-reasoning-replay-batch.test.ts tests/responses-tools-parity.test.ts (pass)
  • bun run typecheck (clean)
  • bun run privacy:scan (passed)
  • git diff --check (clean)

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.
  • I pushed my PR to the latest dev commit.
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved tool-call argument handling by safely converting whole-number decimal values to integers where required.
    • Preserved meaningful decimal values and prevented unintended changes to fields that support fractional numbers.
    • Improved compatibility when tool names use alternate or namespaced forms, ensuring the correct parameter rules are applied in both streaming and non-streaming responses.
  • Tests

    • Added coverage for native integer fields, schema variations, aliases, and streaming behavior.

Copilot AI lite review requested due to automatic review settings August 22, 2026 08:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the bug Something isn't working label Aug 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 65811d2d-be5e-411b-a467-09b484717d0c

📥 Commits

Reviewing files that changed from the base of the PR and between ced9a85 and c4e3860.

📒 Files selected for processing (4)
  • src/bridge.ts
  • src/lib/tool-argument-integers.ts
  • src/server/responses/collaboration.ts
  • tests/tool-argument-integers.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds native integer property repair for tool-call arguments, resolves parameter schemas across bare and namespaced tool names, and applies the lookup in streaming and buffered bridge paths. Tests cover schema-aware, schema-free, and alias-based repair cases.

Changes

Integer argument repair

Layer / File(s) Summary
Native integer coercion rules
src/lib/tool-argument-integers.ts
Adds known Codex integer property handling, recursive property-name propagation, empty-argument handling, and repair when the parameter schema is missing.
Tool schema alias registration
src/server/responses/collaboration.ts
Registers parameter schemas under tool-choice aliases and preserves bare tool-name entries.
Bridge integration and validation
src/bridge.ts, tests/tool-argument-integers.test.ts
Uses alias-aware schema lookup in streaming and buffered paths. Tests cover integral floats, non-integral values, non-integer fields, missing schemas, and both alias directions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to c4e38

This localized change repairs integral floating-point tool arguments while preserving fractional values and non-integer fields; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: repairing integral float arguments for native integer tool fields.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

Hygiene

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 64 / 80

설명: 이 PR은 이슈 #2316 이 말한, Grok 이 보낸 정수 도구 인자가 120000.0 으로 남아 Codex 가 도구를 실행하기 전에 거절하는 구멍을 막는다. 지금 CURRENT dev HEAD 는 ced9a85c5 이다. origin/dev 는 지난 시간과 같은 커밋이다. 이미 #1611 수리가 src/lib/tool-argument-integers.ts 에 있다. 그런데 그 수리는 스키마가 integer 일 때만 숫자를 다시 쓴다. wait_agent 의 timeout_ms 는 스키마가 number 이고, Codex Rust 쪽은 u64 다. 그래서 지금 HEAD 에서는 스키마를 찾아도 .0 이 남는다. 브리지는 또 toolParameterSchemas.get(currentToolCall.name) 만 본다. 스키마는 multi_agent_v1__wait_agent 로 등록되고, Grok 은 맨이름 wait_agent 를 내보낸다. 키가 안 맞으면 수리가 아예 안 탄다. 이 변경은 세 곳을 고친다. 알려진 네이티브 정수 필드 이름 집합을 두고, 스키마가 number 이거나 스키마를 못 찾아도 그 이름이면 다시 쓴다. lookupToolParameterSchema 가 와이어 이름과 맨이름을 서로 찾는다. collaboration 은 별칭에도 스키마를 넣는다. 테스트는 120000.0 -> 120000, 1.5 는 그대로 실패, temperature 단독은 안 건드림, 스키마 없음, 스트리밍/비스트리밍 별칭을 잠근다. 체크리스트 4칸이 채워져 있고 드래프트가 아니다. 넓은 이름 집합이 걱정이다. timeout_ms 만이 아니라 line, start, end, port, priority, session_id 까지 들어 있다. 스키마가 없을 때도 그 키를 정수로 본다. 스트리밍 테스트는 timeout_ms 를 고치면서 같은 객체의 temperature 1.0 도 JSON.stringify 때문에 1 이 된다. 단독 테스트는 temperature 를 안 건드린다고 잠근다. 카탈로그 팁은 Ox Alpha x-preview-f-free + deepseek-v4-flash-vision-exp. package.json 은 2.27.0. Cursor #2334 는 여전히 미연결. #2332 H2 는 discovery 전용. #2320 overflow + #2342 는 이미 dev. #2188 사이드카는 이미 dev. 사용자 길이 거절 루프라서 64.

src/lib/tool-argument-integers.ts CODEX_NATIVE_INTEGER_PROPERTY_NAMES - timeout_ms만이 아니라 line/start/end/port 까지 이름만으로 정수 취급한다. 스키마 없어도 탄다
src/lib/tool-argument-integers.ts lookupToolParameterSchema - 와이어 이름과 맨이름을 서로 찾는다. 이슈가 말한 키 불일치를 막는다
src/bridge.ts coerceIntegerToolArguments 호출 두 곳 - get(name) 대신 lookup 을 쓴다. 스트리밍과 JSON 경로가 같다
src/server/responses/collaboration.ts toolChoiceAliases - 별칭에도 스키마를 넣는다. lookup 과 겹치지만 해롭지 않다
tests/tool-argument-integers.test.ts 스트리밍 기대값 temperature:1 - timeout_ms 수리 뒤 stringify 부작용이다. 단독 테스트는 1.0 원문을 지킨다

메인테이너의 판단이 필요한 지점

너의 추천
머지 후보다. 이름 집합에서 line/start/end/port 처럼 흔한 키는 빼는 편이 안전하다. timeout_ms, yield_time_ms, max_tokens, session_id 만 남겨도 #2316 은 막힌다. types.ts/config.ts 스플릿과 무관하다. 리베이스하지 말고 이 브랜치를 쓴다. #2334 미연결 라우터, #2359 카탈로그 제외와 묶지 않는다. 라벨은 그대로 둔다. 프리뷰 배포가 아니다. bun test tests/tool-argument-integers.test.ts 가 이 브랜치에서 통과한 뒤에 머지한다.

이 댓글은 grok-bot이 작성했습니다

lidge-jun added a commit that referenced this pull request Aug 22, 2026
Opens devlog/_plan/260822_backlog_disposition_program/ as the planning unit for
clearing the open PR/issue backlog by explicit per-item disposition.

000  objective, 45-PR inventory captured at unit open, disposition classes, and the
     dependency-ordered wp0-wp9 map
001  baseline verifier evidence actually run at unit open (tool-argument-integers
     24 pass, tsc exit 0), remote host state, and repository authority
002  A-phase audit synthesis: round 1 returned FAIL with 7 blockers, all accepted
     with zero rebuttals, each re-verified against the tree before disposition
003  live drift at the A gate (45 -> 50 open PRs) and the disposition of competitor
     PR #2360, which fixes the same issue as wp3
010  wp1 green-and-ready merges, with per-PR verified change maps
020  wp2 changes-requested rebuilds, including the full 16-PR roster the audit
     found missing
030  wp3 #2316, re-scoped by the audit to a single file after the bare-name alias
     was shown unreachable behind the bridge authorization guard
040  wp4 #2292 Windows picker, with a bounded subprocess seam
050  wp5 #2221 native main token refresh, with external-writer CAS promoted into
     acceptance criteria
060  wp6 #1049, recorded as deferred: it needs a crash-safe publisher phase first
070  wp7 Bun 1.4 memory stack retarget, preserving the recorded FAIL verdicts
080  wp8 conflicting and remaining PR disposition

Docs only: no production file is touched by this commit, and nothing in the build,
typecheck, or test path reads from devlog/. privacy:scan passes.
@lidge-jun

Copy link
Copy Markdown
Owner

@lidge-jun lidge-jun closed this Aug 22, 2026
@lidge-jun

Copy link
Copy Markdown
Owner

Landed via #2371 at ae05672

@lidge-jun lidge-jun added the landed-via-maintainer Original PR closed after landing via a maintainer merge train label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working landed-via-maintainer Original PR closed after landing via a maintainer merge train review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants