Repository navigation
fix(llm): preserve explicit zero max_completion_tokens in chat template - #12812
weizhoublue wants to merge 1 commit into
Conversation
Signed-off-by: weizhoublue <[email protected]>
|
👋 Hi weizhoublue! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
WalkthroughThe OpenAI chat completion template now applies ChangesCompletion Token Defaults
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/llm/src/http/service/openai.rs (1)
4479-4499: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winVerify the rejection path in the regression test.
The test confirms that
Some(0)survives template application and thatNonereceives the default. It does not confirm that validation rejects the preserved zero. Add a minimally valid request and assert the expected validation error after applying the template.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/llm/src/http/service/openai.rs` around lines 4479 - 4499, The regression test test_chat_completions_template_preserves_explicit_zero_max_completion_tokens should also exercise validation: after applying the template to a minimally valid request with max_completion_tokens set to Some(0), invoke the existing request-validation path and assert the expected rejection error, while preserving the current assertions for zero preservation and None defaulting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lib/llm/src/http/service/openai.rs`:
- Around line 4479-4499: The regression test
test_chat_completions_template_preserves_explicit_zero_max_completion_tokens
should also exercise validation: after applying the template to a minimally
valid request with max_completion_tokens set to Some(0), invoke the existing
request-validation path and assert the expected rejection error, while
preserving the current assertions for zero preservation and None defaulting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 92346602-2b11-42e1-8e0d-b4c1155f0570
📒 Files selected for processing (1)
lib/llm/src/http/service/openai.rs
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
This PR has been closed due to inactivity. If you believe this PR is still relevant, please feel free to reopen it with additional context or information. |
Overview:
Silent Validation Bypass: Explicit
max_completion_tokens: 0Escapes Rejection When a Request Template Is ConfiguredDetails:
When a client explicitly sent
max_completion_tokens: 0, an illegal value that should be rejectedthe code
request.max_completion_tokens.unwrap_or(0) == 0silently replaced it with the template's default value (e.g. 128 ). By the time validation ran, it saw 128, not 0.So the illegal input got laundered into a legal one, and the validation error never fired:
The
--template-filefeature should not turn an illegal input into a legal one. It exists to fill in omitted fields, not to override an explicit (even if invalid) value the client sent.Fix:
request.max_completion_tokens.is_none()This only fills in the template default when the field is truly absent (omitted). An explicit 0 stays 0 , reaches validation, and is correctly rejected with "Max completion tokens must be greater than 0".
Where should the reviewer start?
Related Issues
🔗 This PR is linked to an issue:
🚫 This PR is NOT linked to an issue:
Summary by CodeRabbit
Bug Fixes
0.Tests