Skip to content

fix(responses): give tool_search_call and custom_tool_call their own id prefixes - #2173

Merged
lidge-jun merged 1 commit into
devfrom
codex/audit-tool-search-id
Aug 20, 2026
Merged

fix(responses): give tool_search_call and custom_tool_call their own id prefixes#2173
lidge-jun merged 1 commit into
devfrom
codex/audit-tool-search-id

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

Release audit of origin/main..origin/dev found this by composing two changes that are each correct alone — the shape the audit was specifically looking for.

The defect. A routed tool_search lowering is restored as a tool_search_call with no id (#2145), and the universal output-item id backfill then names it (#2142). The backfill's prefix table had no entry for the type, so it fell through to the generic item_:

{"type":"tool_search_call","call_id":"call_x",...}  ->  id: "item_ocx_0"
{"type":"function_call","name":"x",...}             ->  id: "fc_ocx_0"

That is not cosmetic. stripInvalidItemIds in the Responses adapter deletes any id whose prefix does not match its type, and it lists tsc_ as the only valid prefix for tool_search_call. So the synthesized id survived the turn that created it and was silently dropped on the next one, leaving the client an item it could not correlate.

Neither PR's focused suite caught it, because neither composes missing-id restoration with the backfill. That is exactly why this needed a cross-PR pass rather than per-PR CI.

custom_tool_call had the identical gap and is fixed alongside it: the serializer enforces ctc_, the backfill did not know the type.

The two tables are now a stated invariant — the backfill's prefixes must remain a superset of the ones the serializer enforces — recorded in a comment at the table so the next type added does not reopen it.

Verification

  • RED-first. Reverting only src/server/responses/responses-field-backfill.ts fails exactly the two new tests (20 pass / 2 fail).
  • bun x tsc --noEmit — exit 0.
  • bun test --isolate tests/responses-field-backfill.test.ts — 22 pass / 0 fail.
  • bun run test on ssh lidge13717 pass / 15 skip / 0 fail across 866 files.
  • bun run privacy:scan — passed.

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.

No credential or auth surface is touched; this only changes a synthesized id prefix.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected backfilled tool-search and custom tool-call IDs to use the appropriate serializer-compatible prefixes.
    • Improved consistency and compatibility of generated response item identifiers.
  • Tests

    • Added regression coverage for tool-search and custom tool-call ID generation.

…id prefixes

The release audit found this by composing two changes that are each
correct alone. A routed tool_search lowering is restored as a
tool_search_call with no id (#2145), and the universal output-item id
backfill then names it (#2142) -- but the backfill's prefix table had no
entry for the type, so it fell through to the generic "item_".

That is not cosmetic. stripInvalidItemIds in the Responses adapter deletes
any id whose prefix does not match its type, and it lists tsc_ as the only
valid prefix for tool_search_call. So the synthesized id survived the turn
it was created in and was silently dropped on the next one, leaving the
client an item it could not correlate.

Neither PR's focused suite caught it because neither composes missing-id
restoration with the backfill.

custom_tool_call had the same gap and is fixed with it: the serializer
enforces ctc_, the backfill did not know the type.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 20, 2026 04:24
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

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

coderabbitai Bot commented Aug 20, 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: dfc455ec-b2e0-40b5-accf-6021d2057352

📥 Commits

Reviewing files that changed from the base of the PR and between b9dfc78 and 8e2d42b.

📒 Files selected for processing (2)
  • src/server/responses/responses-field-backfill.ts
  • tests/responses-field-backfill.test.ts

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


📝 Walkthrough

Walkthrough

The Responses field backfill now generates tsc_ IDs for tool_search_call items and ctc_ IDs for custom_tool_call items. Regression tests verify both prefixes.

Changes

Responses ID backfill

Layer / File(s) Summary
Add serializer-compatible call ID prefixes
src/server/responses/responses-field-backfill.ts, tests/responses-field-backfill.test.ts
The prefix table maps tool_search_call to tsc_ and custom_tool_call to ctc_. Tests confirm missing IDs become tsc_ocx_ and ctc_ocx_ IDs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 8e2d4

This narrowly corrects synthesized tool-call ID prefixes with focused tests and no actionable merge-blocking risk remains.

Possibly related PRs

Suggested labels: review-ready

Suggested reviewers: ingwannu, bet4it

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding dedicated ID prefixes for tool_search_call and custom_tool_call.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/audit-tool-search-id

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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 70 / 80

#2145랑 #2142를 붙이면 나오는 구멍임. 라우티드 tool_search가 tool_search_call로 복원되는데 id가 없음. 백필이 타입 테이블에 없어서 item_ocx_0을 줌. stripInvalidItemIdstsc_만 인정해서 다음 턴에 id가 조용히 사라짐. 클라이언트가 아이템을 못 이음. 각자 스위트는 조합을 안 돌려서 통과함. custom_tool_call도 동일. 시리얼라이저는 ctc_, 백필은 모름.

백필 prefix가 시리얼라이저가 강제하는 집합의 상위집합이어야 함. 테이블 주석으로 박은 거 맞음. types.ts/config.ts 안 건드림. MERGEABLE.

점수는 70임. 2.28에 넣어야 함. #2145+#2142가 이미 dev에 있어서 지금 깨진 상태임.

해결방안: 머지. tsc_/ctc_ 테스트 유지. 새 output 타입 넣을 때 두 테이블 같이.

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

@lidge-jun
lidge-jun merged commit b2878f8 into dev Aug 20, 2026
25 of 27 checks passed
@lidge-jun
lidge-jun deleted the codex/audit-tool-search-id branch August 20, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant