Repository navigation
fix(llm): align stop-sequence limits and return 400 - #14462
Conversation
|
👋 Hi flpanbin! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughChangesOpenAI stop sequence limits
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to OpenAI requests with more than four stop sequences or stop token IDs now receive clear validation failures rather than reaching the engine path. The shared enforcement and boundary coverage indicate no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
8cfb970 to
ac674b6
Compare
|
/ok to test 9c4e4ab |
9c4e4ab to
d25c5c9
Compare
|
Hi @rmccorm4, One follow-up thought: the stop-limit checks in this PR now return typed Is the intent that validation errors should generally be typed |
|
/ok to test ff62e88 |
Overview:
Fixes the opaque HTTP 500 returned when a chat/completion request contains more than 4
stop(orstop_token_ids) entries. The request now fails fast at the HTTP boundary with a clear 400 validation error, and the two previously inconsistent stop-sequence limits in the codebase are aligned to a single constant.Details:
The bug had two layers:
MAX_STOP_SEQUENCES = 32invalidate.rs), while request extraction bailed at more than 4 (hard-coded inopenai.rs::extract_stop_conditions).anyhow::bail!, which the HTTP error mapper could not classify, so it fell through to the generic "Failed to generate completions" 500.Changes:
lib/llm/src/protocols/openai/validate.rsMAX_STOP_SEQUENCEStightened from 32 to 4, matching the OpenAI API contract.lib/llm/src/protocols/openai.rsextract_stop_conditionsnow uses the sharedMAX_STOP_SEQUENCESconstant instead of a hard-coded 4, with corrected messages.The 500→400 fix is structural, validation now rejects over-limit requests at the entry point, so they never reach the engine path that produced the opaque 500.
Where should the reviewer start?
lib/llm/src/protocols/openai/validate.rs— the constant, the twovalidate_stopmessages, and the newstop_token_idscount check invalidate_no_unsupported_fields.lib/llm/src/protocols/openai.rs—extract_stop_conditionsbackstop now shares the same constant.validate.rsandchat_completions.rsValidation
cargo test -p dynamo-llm --lib protocols::openaicargo clippy -p dynamo-llm --libcargo fmt -p dynamo-llmRelated Issues
🔗 This PR is linked to an issue:
stop/stop_token_idswith more than 4 entries returns opaque 500 instead of a 400 validation error #14463🚫 This PR is NOT linked to an issue:
Summary by CodeRabbit