Fix responses funtion call output - #4431
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new parsing/normalization behavior (array output + missing/invalid output handling) should be covered by unit tests to prevent regressions in Responses-to-chat translation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds normalization for OpenAI Responses API function_call_output.output so tool outputs can be consumed reliably when the output is delivered as either a string or an array of typed content items, improving compatibility with Responses payload variants.
Changes:
- Introduces
normalizeFunctionCallOutput()to convertfunction_call_output.outputinto a single string (extractinginput_text/output_textwhen present, otherwise JSON-stringifying the array). - Updates
ResponsesInputBuilder::onFunctionCallOutputItem()to require anoutputfield and to use the new normalization path before emitting tool messages.
File summaries
| File | Description |
|---|---|
| src/llm/apis/openai_responses.cpp | Normalizes function_call_output.output (string/array) into a tool message content string and adds stricter validation for missing output. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| static absl::StatusOr<std::string> normalizeFunctionCallOutput(const rapidjson::Value& outputValue) { | ||
| if (outputValue.IsString()) { | ||
| return std::string(outputValue.GetString()); | ||
| } | ||
| if (!outputValue.IsArray()) { | ||
| return absl::InvalidArgumentError("function_call_output.output must be a string or array"); | ||
| } |
🛠 Summary
JIRA/Issue if applicable.
Describe the changes.
🧪 Checklist
``