Repository navigation
[None][fix] Responses: resolve namespace::tool calls and restore a dropped namespace on replay - #21056
Conversation
…opped namespace on replay The Codex CLI declares its tools under namespaces, and the Responses endpoint offers them to the model as "namespace.tool". Models also write the bare name and, for DeepSeek-V4.1-Flash, "namespace::tool". The bare name already resolved; "namespace::tool" did not, so the call reached the client as a function call to an unknown tool, and a custom tool lost its custom_tool_call shape. - _tool_resolution maps "namespace::tool" to the same tool as "namespace.tool". The spelling never displaces a declared name, and the bare-name rule is unchanged. The stream and the final snapshot share the resolution, so they agree. - When the input is converted to chat messages, a call echoed back without its namespace is replayed under its qualified name if exactly one namespaced tool and no top-level tool has that bare name, so the history matches the tool list. Any other name is replayed as received. Signed-off-by: JunyiXu-nv <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Build declared-tool mappings tensorrt_llm/serve/responses_utils.py, tests/unittest/llmapi/apps/test_responses_custom_tools.py |
The mapping records exposed and namespace::tool spellings. Tests cover dotted, bare, and :: names, ambiguous bare names, and precedence for exact top-level declarations. |
Apply resolution during input replay tensorrt_llm/serve/responses_utils.py, tests/unittest/llmapi/apps/test_responses_custom_tools.py, tests/unittest/llmapi/apps/test_responses_input_preprocess.py |
Input conversion passes the declared-tool mapping when replaying function and custom-tool calls. A bare name gains its namespace only when it has a unique namespaced owner; other names remain unchanged. |
Check streaming and final call consistency tests/unittest/llmapi/apps/test_responses_streaming_tool_calls.py, tests/unittest/llmapi/apps/test_responses_stream_final_consistency.py |
Tests compare streamed calls with final snapshots across parsers, name spellings, and chunk sizes. They also check namespaced custom-tool output in streaming and final responses. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: qijune
Merge Risk: 
Minimal · up to a5e10
-
The namespaced tool-call changes have relevant replay and streaming tests, with no identified issue requiring a fix before merge.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title follows the repository template: it has a [None] ticket tag, a [fix] type, and a summary. It names the two main changes: resolving namespace::tool calls and restoring a dropped namespace on replay. This matches the raw summary and the objectives, which describe namespaced tool resolution in responses_utils.py and the replay rule for calls without a namespace.
Full details: Description check
-
Explanation
The description follows the repository template. It has a Description section that explains the Codex namespace problem, the three spellings, the two fixes, and what is not changed. It has a Test Coverage section that lists the four test files, their cases, and the reported pass counts. The PR Checklist is reduced to a single checked item and does not include the other checklist items from the template. The template's title-format line is not repeated in the description, which is acceptable because the title itself follows the format.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 25 functions across 5 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
/bot run --disable-fail-fast |
|
PR_Github #80737 [ run ] triggered by Bot. Commit: |
|
Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements. |
|
PR_Github #80737 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
👎 Promotion blocked, new vulnerability foundVulnerability report
|
|
/bot run --disable-fail-fast |
|
PR_Github #80877 [ run ] triggered by Bot. Commit: |
|
PR_Github #80877 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #80895 [ run ] triggered by Bot. Commit: |
|
PR_Github #80895 [ run ] completed with state |
Description
The Codex CLI declares its tools under namespaces.
execis a custom (freeform) tool in thefunctionsnamespace, andspawn_agentis a function in thecollaborationnamespace. A chattemplate can only show a flat list of functions, so the Responses endpoint offers these tools as
functions.execandcollaboration.spawn_agent. It reports each call back to the client as abare
nameplus anamespace.Models write a namespaced tool's name in three ways:
functions.exec, the name in the tool list;exec, the name the client's own instructions use;functions::exec, the separator DeepSeek-V4.1-Flash uses for namespaced tools in its toolschema and in its calls.
_tool_resolutionalready resolves the first two. The third matched no declared tool, so thecall went out as a
function_callnamedfunctions::execwith no namespace. The client answerssuch a call with "unsupported call". For
exec, the call also lost its custom-tool shape(
custom_tool_callwithinput).There is a second, related problem. The client sometimes echoes a call back in the next request
without its
namespacefield. The history was then rendered with the bare nameexec. That nameis not in the tool list the model was given, so the history no longer matched the tools.
This PR changes
tensorrt_llm/serve/responses_utils.py:namespace::toolnow resolves exactly likenamespace.tool. A custom tool still comes out ascustom_tool_callwithinput. The streamed items and the final snapshot use the sameresolution, so they agree. This spelling never displaces a name that a tool was declared
under. The bare-name rule is unchanged: a bare name resolves only when exactly one declared
tool has it.
function_callorcustom_tool_callthat arrives without anamespaceis replayed under its qualified name, ifexactly one namespaced tool and no top-level tool has that bare name. Any other name is
replayed as received. A call that keeps its namespace is replayed as before. The same
conversion feeds the router's prompt rendering, so the router sees the same history.
Not changed:
functions.exec.Showing the
::spelling there is a separate decision.::name as text.the model wrote
functions::execorexec. After such a call, the next prompt thereforediffers from the tokens the model generated, so prefix-cache reuse stops at that call.
Main already behaves this way for calls echoed with their namespace.
Test Coverage
All new tests are CPU tests in files that
l0_cpu.ymlalready lists.tests/unittest/llmapi/apps/test_responses_custom_tools.py::) of a namespaced custom tool and of a namespaced function.functions:exec,::execandfunctions::.They are reported as written.
spellings still resolve.
for an ambiguous name, a top-level owner, no tools, and a name that is not bare.
tests/unittest/llmapi/apps/test_responses_input_preprocess.py: a whole request shaped likethe Codex CLI's (tools in an
additional_toolsitem) with two calls echoed without theirnamespaces.
tests/unittest/llmapi/apps/test_responses_streaming_tool_calls.py: all three spellingsthrough the DeepSeek-V4.1 and Qwen3 tool parsers at several chunk sizes. The streamed items,
the snapshot of the streamed response and a snapshot built without streaming all agree.
tests/unittest/llmapi/apps/test_responses_stream_final_consistency.py: afunctions::execcall through the streaming processor with a namespace declared in the request. The streamed
custom_tool_callequals the one in the terminal snapshot.On a build of current main, the four files pass: 187 tests, 31 of them new, against 156 before.
The resolution and the replay rule were also checked as properties over generated tool sets,
with a mutation gate that plants bugs in both. That check is not part of this PR.
PR Checklist
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.🤖 Generated with Claude Code
Dev Engineer Review
The resolver uses the request’s declared tools to map dotted and
namespace::toolspellings to namespaced tools. It qualifies a bare name only when exactly one namespaced tool matches and no top-level tool has that name. Function and custom-tool replay use this resolution. Test results and review severity counts are unavailable.QA Engineer Review
Four test files changed. They cover namespaced tool resolution, input replay, and consistency between streamed calls and final snapshots. Cases include dotted, bare, and
namespace::toolspellings, ambiguous names, exact top-level matches, and function and custom-tool payloads. All four files appear intests/integration/test_lists/test-db/l0_cpu.yml. Coverage verdict: sufficient for the described resolution and replay behavior.Per-File QA Perspective
tensorrt_llm/serve/responses_utils.py: Verify that declared namespaced tools resolve consistently for function and custom-tool input replay. Check that ambiguous bare names and exact top-level matches preserve the received spelling.tests/unittest/llmapi/apps/test_responses_custom_tools.py: Covers dotted, bare, and::resolution, unknown and ambiguous spellings, top-level precedence, and replay with a missing namespace. Listed intests/integration/test_lists/test-db/l0_cpu.yml.tests/unittest/llmapi/apps/test_responses_input_preprocess.py: Covers replay of unqualified namespaced custom-tool and function calls into chat tool calls. Listed intests/integration/test_lists/test-db/l0_cpu.yml.tests/unittest/llmapi/apps/test_responses_stream_final_consistency.py: Covers a DeepSeek-V4.1namespace::toolcall and checks the custom-tool shape in streamed output and the final response. Listed intests/integration/test_lists/test-db/l0_cpu.yml.tests/unittest/llmapi/apps/test_responses_streaming_tool_calls.py: Covers streaming and non-streaming parsing across model and spelling variants, with chunk-size comparisons. Listed intests/integration/test_lists/test-db/l0_cpu.yml.