Skip to content

Support namespaced function tools in the Responses API - #38359

Open
PierreLeGuen wants to merge 1 commit into
sgl-project:mainfrom
PierreLeGuen:fix/codex-stateless-responses
Open

PierreLeGuen wants to merge 1 commit into
sgl-project:mainfrom
PierreLeGuen:fix/codex-stateless-responses

Conversation

@PierreLeGuen

@PierreLeGuen PierreLeGuen commented Sep 7, 2026 •

Copy link
Copy Markdown

Motivation

Responses clients such as Codex group client-executed functions under type="namespace". SGLang accepts these declarations but omits their functions from the chat template, and replay can discard the namespace. This prevents a stateless tool-call loop.

Related gateway protocol fixes: smg-project/smg#2451

Modifications

  • Flatten namespace members into qualified model-facing names while preserving each function's schema, description, and strictness.
  • Restore separate name and namespace fields in non-streaming calls and streaming item events, and preserve them on stateless replay.
  • Support named namespace tool selection, reject ambiguous qualified names, and validate namespace membership shape. Custom tools and hosted tools retain their existing behavior.
  • Add regression coverage for duplicate member names in different namespaces, dotted top-level names, collisions, forced selection, streaming, and string/content-array tool results.

Accuracy Tests

No kernel or model-forward changes. Responses unit tests on the patched serving runtime: 50 passed, 4 subtests passed.

cd test/registered/unit/entrypoints/openai
python3 -m pytest -q test_response_namespace_tools.py test_serving_responses.py test_serving_responses_stream.py

Live GLM-5.3-Flash checks passed in both streaming and non-streaming modes: force weather.lookup, verify namespace="weather" and the JSON arguments, then replay the returned call with a content-array tool result and store=false (no previous_response_id). The next response correctly uses the supplied result. Codex CLI 0.153.0 also completed a namespaced MCP call, replayed its result, inspected and edited a Python file through the shell, passed all three fixture tests, and returned the exact synthetic marker from the MCP result.

Speed Tests and Profiling

No inference kernel changes; no throughput claim. The change adds function declaration/name translation at the API boundary.

Checklist

  • Ruff lint/format, isort, codespell, and git diff --check pass for changed files.
  • Added CPU unit tests registered with CI.
  • Followed existing Responses serving/test conventions.
  • Documentation and model accuracy/speed benchmarks: not applicable to the protocol translation tested here.

CI States

Latest PR Test (Base): ❌ Run #34147251332
Latest PR Test (Extra): ❌ Run #34147251186
Latest PR Test (AMD ROCm 7.2): ❌ Run #34147251277

Signed-off-by: Pierre LE GUEN <26087574+PierreLeGuen@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-07T17:25:46.573560Z 02d84e6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@PierreLeGuen

Copy link
Copy Markdown
Author

@JustinTong0323 Could you review this and enable/rerun the required CI? The Base, Extra, and AMD workflows currently stop at the missing run-ci label before tests execute; lint passes. The PR includes regression coverage and validation details, and the companion gateway change is smg-project/smg#2451. Thanks!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant