fix: correct Responses API tool schema and null error classification#772
Closed
telagod wants to merge 1 commit intonullclaw:mainfrom
Closed
fix: correct Responses API tool schema and null error classification#772telagod wants to merge 1 commit intonullclaw:mainfrom
telagod wants to merge 1 commit intonullclaw:mainfrom
Conversation
Two bugs prevented the Responses API (api_mode=responses) from working
with providers like foxnio:
1. Tool schema format mismatch: buildResponsesRequestBody used
convertToolsOpenAI which emits the chat completions nested format
{"type":"function","function":{"name":...}}. The Responses API
requires a flat format {"type":"function","name":...}. Added
convertToolsResponses with the correct flat structure.
2. Null error misclassification: Responses API returns "error":null in
successful responses. classifyErrorObject treated any non-string,
non-object error field as .other (an error), causing valid completed
responses to be rejected. Added a null check to skip classification
when error is explicitly null.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two bugs prevented the Responses API (
api_mode=responses) from working with providers that implement the OpenAI Responses endpoint (e.g. foxnio):Fixes #773
1. Tool schema format mismatch
buildResponsesRequestBodycalledconvertToolsOpenAI, which emits the chat completions nested format:{"type": "function", "function": {"name": "...", "description": "...", "parameters": {...}}}The Responses API requires a flat format:
{"type": "function", "name": "...", "description": "...", "parameters": {...}}This caused providers to reject requests with
Missing required parameter: 'tools[0].name'.2. Null error misclassification
Responses API returns
"error": nullin successful responses.classifyErrorObjecttreated any non-string, non-objecterrorfield value as.other(an API error), causing valid completed responses to be rejected as errors.Changes
src/providers/helpers.zigconvertToolsResponseswith flat tool schema formatsrc/providers/root.zigconvertToolsResponsessrc/providers/compatible.zigbuildResponsesRequestBodynow callsconvertToolsResponsessrc/providers/error_classify.zigclassifyErrorObjectskips"error": nullinstead of misclassifying itValidation
zig build test --summary all: 6337 passed, 0 failures, 0 leaksnullclaw agent --no-stream