Skip to content

fix(converter): accept hosted and deferred tools when unrepresentable request fields are dropped - #5035

Open
cmunley1 wants to merge 4 commits into
mainfrom
cmunley1/request-tolerance-tools
Open

cmunley1 wants to merge 4 commits into
mainfrom
cmunley1/request-tolerance-tools

Conversation

@cmunley1

Copy link
Copy Markdown
Contributor

What broke

An agent harness that sends Codex-style Responses requests to a model served by vllm_model loses the rollout on the first request whenever the client declares a tool the converter does not implement:

  • a hosted tool (web_search_preview, file_search, tool search) raises NotImplementedError: Responses tool type '...' has no implemented Chat Completions conversion
  • any tool with defer_loading: true raises NotImplementedError: Responses function tools with defer_loading enabled have no Chat Completions representation

Codex declares both, so the request is refused before a single token is generated.

A second and separate failure hits the replay path. An output_text with "annotations": null fails validation, and an assistant message carrying "routed_experts": null fails validation at NeMoChatCompletionAssistantMessageForTrainingParam. 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_fields opt-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:

  • under the flag, a hosted tool is dropped with a debug log, since a backend reached through Chat Completions cannot run it
  • under the flag, a tool with defer_loading is declared eagerly without that key, since this conversion has no tool-search step and dropping the definition would lose the tool

The method docstring and the vllm_model field 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 annotations becomes [], and a null routed_experts is 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: true in its vllm_model config 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 (parameterized web_search_preview and file_search) and for defer_loading on function and custom tools, flag-path tests that assert the tool is dropped or declared eagerly, and positive tests for null annotations and null routed_experts
  • responses_api_models/vllm_model/tests/test_app.py: server-level default-path reject and flag-path drop inside TestUnrepresentableRequestFields, matching the existing include coverage
  • tests/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 path

Results: 710 passed across the four affected unit test modules, 332 passed across vllm_model and vllm_model_with_compaction, ruff check and ruff format clean, and pre-commit run --files over 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.

… 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]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cmunley1
cmunley1 marked this pull request as ready for review October 24, 2026 01:24
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 21b5193

@cmunley1

Copy link
Copy Markdown
Contributor Author

/review

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 24, 2026 01:25
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:model Model servers, inference providers, and model adapters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Oct 24, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 47bec9b

@cmunley1

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 8d31d68

@cmunley1

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@cmunley1

Copy link
Copy Markdown
Contributor Author

/ok to test 795172c

@cmunley1

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cmunley1
cmunley1 requested a review from yaoyu-33 November 11, 2026 21:19
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 12, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"}:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, often defer_loading ones). Only the streaming path flattens it first (sanitize_streaming_responses_body). A non-streaming /v1/responses request 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, and tool_search with execution: "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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yaoyu-33

Copy link
Copy Markdown
Contributor

/ok to test 795172c

@github-actions github-actions Bot added sla:author-overdue Author response is over the one-business-day SLA and removed sla:review-overdue Review response is over the one-business-day SLA labels Nov 17, 2026

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model servers, inference providers, and model adapters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:author-overdue Author response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants