Skip to content

fix: fix tool-search in response api - #2434

Open
hustxiayang wants to merge 2 commits into
envoyproxy:mainfrom
hustxiayang:tool-search
Open

fix: fix tool-search in response api#2434
hustxiayang wants to merge 2 commits into
envoyproxy:mainfrom
hustxiayang:tool-search

Conversation

@hustxiayang

@hustxiayang hustxiayang commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Currently, ai-gateway did not recognize tool_search_call and tool_search_output in responses input/output item unions. This caused two errors:

  1. When parsing a response output item for a non-streaming request, ai-gateway can fail a valid upstream response with: unknown_type_field_value_'tool_search_call'_for_response_output_item_union
    This is because the response output union does not know that type, parsing hits the output-union default error:

    func (r *ResponseOutputItemUnion) UnmarshalJSON(data []byte) error {
    . For streaming requests, this error is not visible because ai-gateway skips SSE event decode errors.

  2. When parsing a later request that resends prior output items as input, ai-gateway would reject the request with:
    cannot unmarshal unknown input type: tool_search_call This is because response input union does not know that type:

    func (r *ResponseInputItemUnionParam) UnmarshalJSON(data []byte) error {

Fix Add tool_search_call and tool_search_output to both unions.
Other Schema Items Added:

  • additional_tools
  • compaction_trigger
  • computer_call_output
  • custom_tool_call_output
  • mcp_approval_response

Signed-off-by: yxia216 <yxia216@bloomberg.net>
@hustxiayang
hustxiayang requested a review from a team as a code owner July 27, 2026 19:08
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 27, 2026
@hustxiayang
hustxiayang marked this pull request as draft July 27, 2026 19:08
@hustxiayang
hustxiayang marked this pull request as ready for review July 27, 2026 20:13
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.81%. Comparing base (e2c59d3) to head (d513123).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/apischema/openai/openai.go 71.42% 10 Missing and 10 partials ⚠️

❌ Your patch status has failed because the patch coverage (71.42%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2434      +/-   ##
==========================================
- Coverage   84.86%   84.81%   -0.05%     
==========================================
  Files         154      154              
  Lines       22419    22489      +70     
==========================================
+ Hits        19026    19075      +49     
- Misses       2237     2248      +11     
- Partials     1156     1166      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants