Repository navigation
fix(converter): accept hosted and deferred tools when unrepresentable request fields are dropped - #5035
fix(converter): accept hosted and deferred tools when unrepresentable request fields are dropped#5035cmunley1 wants to merge 4 commits into
Conversation
… to drop A Responses request that declares a hosted tool (web search, tool search) or a tool with defer_loading still raises NotImplementedError by default, so the caller can route the request to a server that serves Responses natively. Under drop_unrepresentable_request_fields both convert: a hosted tool is dropped, since a model served outside the provider cannot call it, and a deferred tool is declared eagerly, since this path has no tool-search step. Replayed output validates too. An output_text with `annotations: null` becomes `[]`, and an assistant message with `routed_experts: null` keeps the null. Both are shapes a client sends when it echoes back what it received, so a history that came from a dense model used to fail on the next request. One streaming test asserted that null annotations are malformed. That case is dropped and replaced with a positive one, since the same field serves the replay path. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 21b5193 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — one RISK: dropping every declared tool bypasses the converter’s existing no-tools handling and can still fail the request.
Reviewed all six changed files and traced streaming dispatch, replay validation, custom-tool conversion, and vLLM forwarding. The null-field relaxations and default fail-loud behavior otherwise look consistent with the inspected contracts.
Static review only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
…-tools request Review follow-up. Under drop_unrepresentable_request_fields a request that declares only hosted tools (web_search_preview) converted to tools: [] while keeping tool_choice and parallel_tool_calls, which vLLM rejects. The no-tools branch now follows the converted tools instead of the original list, so such a request drops tools, tool_choice and parallel_tool_calls like any request without tools, and tool_choice "required" still raises "requires at least one tool". Tests: hosted-only tools with tool_choice omitted, auto and none carry none of the three fields. Hosted-only with required raises. A surviving function next to a hosted tool keeps tool_choice required. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 47bec9b |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — LGTM, no reliability concerns in the follow-up changes.
Verified the prior RISK is resolved: the converter now applies no-tools handling after filtering. Hosted-only requests omit tools, tool_choice, and parallel_tool_calls; required still raises when no tool survives. The regression tests assert those outcomes and preserve required for a surviving function.
Compared the follow-up with the previous reviewed tree, accounted for all six changed files, and traced streaming/non-streaming dispatch and backend forwarding. No unresolved prior findings or eligible introduced regressions remain.
Static review only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
…ages An OpenAI SDK client (mini-swe-agent) replays the previous assistant message as the SDK dumped it, which includes "annotations": null. The assistant message param did not declare the field, so the second turn failed with 422 extra_forbidden and the agent stopped after one step. The field is now accepted, and the vLLM model server drops it from every message before the request reaches the engine, next to the existing strict strip, so chat templates never see it. Tests: a chat request whose assistant history carries annotations: null validates, and the payload forwarded to vLLM has no annotations key. Both fail without the change. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 8d31d68 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — LGTM, no reliability concerns in the follow-up changes.
Verified the prior no-tools RISK remains resolved: the post-filter branch omits tool fields when nothing survives and rejects required. The regression assertions retain hosted-only cleanup and required selection for a surviving function.
Compared the follow-up against the previous reviewed tree, accounted for all six changed files, and traced the new assistant-annotations acceptance through validation, conversion, and backend preprocessing. The new server regression asserts replayed null annotations are removed before forwarding. No unresolved prior findings or eligible introduced regressions remain under the follow-up impact filter.
One delegated report was unavailable; its prior-fix/replay topic was checked directly. Static review only; tests were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
Resolve conflicts with main. Signed-off-by: Christian Munley <[email protected]>
|
/ok to test 795172c |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — LGTM, no eligible findings in the follow-up changes.
Verified that the prior no-tools RISK remains resolved: the post-filter branch removes tool fields when no definition survives and rejects required. The regression assertions retain hosted-only cleanup and required selection for a surviving function.
Compared the merge follow-up with the previous reviewed tree, accounting for the module moves and all six changed files. Traced replay validation, training metadata, streaming dispatch, and vLLM forwarding. Null annotations remain accepted through the request cleanup, and the server regression retains the expected annotation-free payload. No unresolved prior findings or proven new regressions above the moderate impact threshold remain.
The tool-conversion child’s report wasn't returned, so I checked that topic directly. Static review only; tests were not executed.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
yaoyu-33
left a comment
There was a problem hiding this comment.
Reviewed at 795172c with a focus on the Responses-to-Chat conversion and the schema loosening. The no-tools follow-up from the earlier bot review is in place and tested. The null annotations → [] and null routed_experts relaxations look right: token capture already skips a null routed_experts (builder.py checks is not None), so training records are unchanged. The default path still fails loudly.
HOLD on one inline blocker: under drop_unrepresentable_request_fields, the tool filter also removes tools the client itself runs. Two risks are inline as well.
Evidence: a direct converter probe on this head with the flag on (namespace, shell, local_shell, apply_patch and a client tool_search all produce tools: null), and a read of the streaming sanitizer. CI core and server suites pass on this head. No model rollout was run.
PR body nit: the test paths in the body (tests/unit_tests/test_responses_converter.py, test_responses_api_model_streaming.py) moved to tests/unit_tests/models/ in the main merge.
| @@ -591,10 +593,19 @@ def responses_to_chat_completion_create_params( | |||
| if tool_dict.get("output_schema") is not None: | |||
| raise NotImplementedError("Responses tool output schema has no Chat Completions representation.") | |||
| if tool_type not in {"function", "custom"}: | |||
There was a problem hiding this comment.
BLOCKER — the drop path also removes tools the client runs, not only hosted ones
chat_completions_converter.py#L595 drops every type other than function/custom. With the flag on, I converted one tool of each of these types on this head. Each came back as tools: null, where main raises NotImplementedError:
namespace: it wraps function/custom tools (NamespaceToolParam, oftendefer_loadingones). Only the streaming path flattens it first (sanitize_streaming_responses_body). A non-streaming/v1/responsesrequest loses every function in the namespace. That contradicts the PR's own rule that a deferred tool is declared eagerly, not dropped.shell,local_shell,apply_patch,computer/computer_use_preview, andtool_searchwithexecution: "client": the agent runs all of these, so they are not hosted tools.
The model then answers without tools the agent expects to be called, and the verifier scores that turn as a model failure, where before the request failed loudly. Could the drop be limited to an explicit hosted set (web_search, web_search_preview, file_search, code_interpreter, image_generation, mcp, and tool_search unless execution == "client")? A namespace would be flattened with flatten_namespace_tools (or still refused), and the client-run types would stay refused. Please also add drop-path tests for a namespace tool and for one client-run type that assert the converted tools.
| raise NotImplementedError( | ||
| f"Responses tool type {tool_type!r} has no implemented Chat Completions conversion." | ||
| ) | ||
| logger.debug( |
There was a problem hiding this comment.
RISK — a change to the model's tool set is logged at debug only
Unlike include or phase, dropping a tool changes what the model can do, and this line is invisible at the default log level. The streaming path's existing _tool_kept logs the same drop at warning. Could this use logger.warning too, so a run whose model never saw a declared tool can be traced from the server log?
| "non-empty `include` (every value), `reasoning.summary` and `reasoning.generate_summary`, and " | ||
| "a message `phase` are dropped and the request proceeds, and so is a `reasoning.context` of " | ||
| "non-empty `include` (every value), `reasoning.summary` and `reasoning.generate_summary`, " | ||
| "a message `phase`, and a declared tool this backend cannot run (a hosted tool such as web " |
There was a problem hiding this comment.
RISK — overlaps drop_hosted_tools, and the docs row is not updated
drop_hosted_tools already drops these types on streaming requests (the Codex path), and the existing Codex config sets both flags. After this PR, two switches control the same drop, with different logging and different namespace handling. Could the description say when each one applies, or could the converter reuse drop_hosted_tools for tools? Please also update the drop_unrepresentable_request_fields row in fern/versions/latest/pages/model-server/vllm.mdx: it still lists only the reporting-only fields.
|
/ok to test 795172c |
What broke
An agent harness that sends Codex-style Responses requests to a model served by
vllm_modelloses the rollout on the first request whenever the client declares a tool the converter does not implement:web_search_preview,file_search, tool search) raisesNotImplementedError: Responses tool type '...' has no implemented Chat Completions conversiondefer_loading: trueraisesNotImplementedError: Responses function tools with defer_loading enabled have no Chat Completions representationCodex declares both, so the request is refused before a single token is generated.
A second and separate failure hits the replay path. An
output_textwith"annotations": nullfails validation, and an assistant message carrying"routed_experts": nullfails validation atNeMoChatCompletionAssistantMessageForTrainingParam. A client that echoes back what it received from a dense model sends both shapes, so a history produced by one turn makes the next request invalid.The fix
Both tool changes are gated on the existing
drop_unrepresentable_request_fieldsopt-in, so the default path is unchanged and stays fail-loud for callers that would rather route the request to a server that serves Responses natively:defer_loadingis declared eagerly without that key, since this conversion has no tool-search step and dropping the definition would lose the toolThe method docstring and the
vllm_modelfield description now name tools among the fields the flag covers.The null-field relaxation is unconditional, because those two are shapes a client replays rather than request fields a backend is asked to ignore: a null
annotationsbecomes[], and a nullrouted_expertsis kept as null.One behavior note: the flag defaults to off on the model server. Harness traffic that sends Codex requests needs
drop_unrepresentable_request_fields: truein itsvllm_modelconfig to take the new path. Without that config change nothing about the default behavior moves.Tests
tests/unit_tests/test_responses_converter.py: default-path reject tests for a hosted tool (parameterizedweb_search_previewandfile_search) and fordefer_loadingon function and custom tools, flag-path tests that assert the tool is dropped or declared eagerly, and positive tests for nullannotationsand nullrouted_expertsresponses_api_models/vllm_model/tests/test_app.py: server-level default-path reject and flag-path drop insideTestUnrepresentableRequestFields, matching the existingincludecoveragetests/unit_tests/test_responses_api_model_streaming.py: the parameterized malformed-input case that asserted null annotations are rejected is replaced with a positive test that keeps the message, since the same field serves the replay pathResults: 710 passed across the four affected unit test modules, 332 passed across
vllm_modelandvllm_model_with_compaction,ruff checkandruff formatclean, andpre-commit run --filesover the six changed files exits 0.Every added test asserts converted output or a raised error. There are no pass-through assertions.
Issue
No issue was opened for this one. It is a small converter gap found while running an agent harness against a served model, and the change is scoped to the one conversion path that hits it.
Rollout evidence: N/A. The tool changes sit behind an opt-in that current rollouts do not set, so measured behavior changes only after a config change, and the null-field relaxation is covered by the streaming and converter tests.