Repository navigation
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Request field and validation tensorrt_llm/serve/openai_protocol.py, tests/unittest/api_stability/references/trtllm_serve_api.yaml, tests/unittest/llmapi/apps/test_openai_protocol_safety_identifier.py, tests/integration/test_lists/test-db/l0_cpu.yml |
ChatCompletionRequest accepts the optional field and ignores it. The API stability reference marks it as an optional string. CPU tests cover accepted and rejected values, default behavior, and compatibility with user; the CPU integration list registers the tests. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related issues
- [Bug]: trtllm-serve /v1/chat/completions rejects the standard OpenAI field safety_identifier with 400 #20962: Adds
safety_identifiertoChatCompletionRequest, addressing the request validation rejection described in the issue.
Possibly related PRs
- NVIDIA/TensorRT-LLM#20864: Adds a similar optional OpenAI compatibility field to
ChatCompletionRequest, with API stability updates and CPU tests. - NVIDIA/TensorRT-LLM#20368: Adds another optional OpenAI compatibility field to
ChatCompletionRequest, with API stability coverage and CPU tests.
Suggested labels: api-compatible
Merge Risk: 
Minimal · up to aec18
-
The change appears ready to merge after normal CI checks. The suspected CPU test-collection failure is not supported by the inspected setup.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
[
#20962] requires/v1/chat/completionsto acceptsafety_identifierinstead of returningextra_forbidden. The supplied PR evidence showsChatCompletionRequestaddssafety_identifier: Optional[str] = None. The field is handled likeuserand is not used for server behavior. The new tests cover keyword and JSON input, theNonedefault, string validation, preservation ofuser, and rejection of unknown fields. The API reference records the field as optional and stable. The issue does not require a length limit. No unmet coding requirement is identified.
Full details: Out of Scope Changes check
-
Explanation
The supplied PR evidence connects every changed file to [
#20962]. The model declaration implements the compatibility field. The new test file verifies the request behavior. The CPU test-list entry enables the test. The API reference row documents the public field, and the API stability test validates it. No unrelated behavior change is shown. References to companion issues do not add their work to this PR.
-
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.
…ions requests OpenAI's Chat Completions API documents safety_identifier as the replacement for the deprecated user field, and OpenAI clients may set it on every request. ChatCompletionRequest is extra="forbid" and has no such field, so these requests fail validation with extra_forbidden. Declare it next to user; like user, the value is accepted and ignored. Adds a CPU unit test, registers it in l0_cpu.yml, and records the field in the trtllm-serve API stability reference. Signed-off-by: Sonica-B <shreyaa.boyane@gmail.com>
c719583 to
aec1891
Compare
Dev Engineer Review
ChatCompletionRequestnow declares optionalsafety_identifier: Optional[str] = None. This allows the request schema to accept the field without changing other fields. The API stability reference records it as optional. The field is accepted for compatibility and is not used for end-user abuse detection.QA Engineer Review
The new unit test covers accepted string values, JSON input, the
Nonedefault, invalid value types, unchanged legacyuserand other dumped fields, and rejection of an unknown field. The CPU test list includes the test file. Coverage verdict: sufficient for the request-schema change. The PR reports 30 passing local tests; this result was not independently verified. No CI result is provided.Per-File QA Perspective
tensorrt_llm/serve/openai_protocol.py— Verify requests with and withoutsafety_identifiervalidate, and omitted values default toNone.tests/unittest/llmapi/apps/test_openai_protocol_safety_identifier.py— Covers accepted and rejected inputs and checks that other request fields remain unchanged. Listed in the CPU CI test list.tests/integration/test_lists/test-db/l0_cpu.yml— Adds the new unit test to the CPU CI list.tests/unittest/api_stability/references/trtllm_serve_api.yaml— Recordssafety_identifieras an optionalChatCompletionRequestfield.Description
OpenAI's Chat Completions API includes
safety_identifier: a stable, hashed end-user ID that OpenAI uses for abuse detection. The OpenAI SDK documentsuseras "being replaced bysafety_identifierandprompt_cache_key", so clients that migrate offusersendsafety_identifierinstead.ChatCompletionRequestinheritsextra="forbid"fromOpenAIBaseModeland declaresuserbut notsafety_identifier, so these requests fail with400 extra_forbidden(#20962).This PR declares
safety_identifier: Optional[str] = Nonenext touser. Likeuser, it is accepted for compatibility and otherwise ignored, because the server does no end-user abuse detection. Unknown fields are still rejected, and other fields are unchanged. It is the companion of #20368 (prompt_cache_key, the other replacement foruser) and follows the same pattern as #20864 (store).Why accept and ignore it rather than act on it: the field only carries meaning for OpenAI's own abuse monitoring. Nothing in
trtllm-servekeys on an end-user identity (useris ignored the same way). Prefix isolation between tenants iscache_salt's job. vLLM accepts the field (extra fields are allowed and logged as ignored); SGLang'sChatCompletionRequestuses Pydantic's default, which drops unknown fields. OpenAI caps the value at 128 characters. That limit is not enforced here, since the value is unused (it matches howuseris declared).Fixes #20962
Label request: this adds a row to
trtllm_serve_api.yaml, so it should carry theapi-compatiblelabel, like #20368 and #20864. I can't set labels from a fork; could a maintainer add it?Test Coverage
tests/unittest/llmapi/apps/test_openai_protocol_safety_identifier.py(new,cpu_only, registered inl0_cpu.yml): the field is accepted from kwargs and from JSON, defaults toNone, rejects non-string values, leaves other fields (includinguser) unchanged, and unknown fields are still rejected.tests/unittest/api_stability/test_serve_api.py: the newChatCompletionRequest.safety_identifierrow inreferences/trtllm_serve_api.yaml(kind: openai,status: stable, defaultnull, not required).openai_protocol.pywas imported directly, with the CUDA-dependenttensorrt_llmpackage__init__s stubbed, becauseimport tensorrt_llmneeds the Linux CUDA build. Results: the new test file,test_openai_protocol_{parallel_tool_calls,tools,mm_processor_kwargs}.pyandtest_serve_api.pygave 30 passed. Without the one-line model change, 5 of the new tests andtest_yaml_fields_exist_on_live_modelfail. CI is the authoritative run.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.