feat(openai): preserve namespace on function_call output items#14789
Merged
feat(openai): preserve namespace on function_call output items#14789
Conversation
When the Responses API dispatches a tool call from inside a `namespace` tool wrapper, the resulting function_call output item carries a `namespace` field identifying which namespace the dispatch came from. The provider's response schema didn't include namespace, so it was stripped during validation and downstream consumers couldn't access it. Adds namespace to the function_call schemas (response output, output items, and response.output_item.done stream events) and surfaces it via providerMetadata.openai.namespace on the resulting tool-call parts. Nullish — no impact when namespace tools aren't in use.
So that streaming consumers can read namespace before the subsequent tool-call event arrives. Useful for downstream layers (e.g. AI Gateway's OpenResponses-compat) that emit completed function_call output items during tool-input-end and would otherwise miss namespace until tool-call arrives a step later.
shaper
reviewed
Apr 28, 2026
felixarntz
reviewed
Apr 28, 2026
Collaborator
felixarntz
left a comment
There was a problem hiding this comment.
@R-Taneja code change looks reasonable, can you add an example that makes use of namespaces for tools so we can verify this? https://developers.openai.com/api/docs/guides/function-calling#defining-namespaces
Two examples under examples/ai-functions/src/{generate-text,stream-text}/openai/
that demonstrate `namespace` flowing through to dispatched function calls
when the model uses server-executed tool_search to find a deferred
function. The generate variant prints providerMetadata.openai on the
tool-call content part; the stream variant prints it on both
tool-input-end and the consolidated tool-call event.
Reviewer ask: #14789 (comment)...
Contributor
Author
added! |
felixarntz
approved these changes
Apr 29, 2026
Contributor
|
✅ Backport PR created: #14910 |
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.
Summary
When the OpenAI Responses API dispatches a tool call from inside a `namespace` tool wrapper, the resulting `function_call` output item carries a `namespace` field identifying which namespace the dispatch came from. Example response from a Codex-style `tool_search` + `namespace` flow:
```json
{
"type": "function_call",
"id": "fc_...",
"call_id": "call_...",
"name": "get_weather",
"arguments": "{"location":"NYC"}",
"status": "completed",
"namespace": "weather_ns"
}
```
The provider's response schema didn't include `namespace`, so zod stripped it during validation. Downstream consumers (e.g. Vercel AI Gateway's OpenResponses-compat layer) couldn't surface namespace information back to clients.
Changes
Optional / nullish, so the change is fully backwards-compatible — no impact on requests that don't use namespace tools.
Test plan
Related
Backports
If accepted, this should also backport to release-v6.0 (and possibly release-v5.0) so existing Codex traffic on the gateway gets the field. Happy to author those backports if the team prefers.