fix(llm): add stop_sequences parity for tool completions#1170
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the LLM system by introducing the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds stop_sequences support for tool completions, achieving parity with regular completions. The changes are well-implemented across the different layers, from the OpenAI compatibility layer through the orchestrator/worker DTOs and down to the Bedrock and NearAI providers. A regression test has also been added. My only suggestion is to refactor some duplicated code in src/channels/web/openai_compat.rs to improve maintainability, which I've detailed in a specific comment.
zmanian
left a comment
There was a problem hiding this comment.
Review: Add stop_sequences to ToolCompletionRequest for parity
Clean, well-scoped fix. ToolCompletionRequest was silently dropping stop sequences from OpenAI compat requests. Now wired through all providers.
Positives:
stop_sequences: Option<Vec<String>>added toToolCompletionRequestwith builder method- All providers updated: bedrock, nearai_chat, openai_compat, proxy (orchestrator + worker)
- Refactored
chat_completions_handlerintobuild_completion_request/build_tool_requesthelpers, eliminating 3x code duplication between streaming/non-streaming/tool paths strip_unsupported_tool_paramscorrectly handlesStopSequencesfor providers that don't support it- Test for strip behavior
LGTM.
* fix(llm): add stop_sequences parity for tool completions * refactor(web-openai): dedupe request builders and satisfy no-panics gate * test(llm): mark multiline assert with safety comment for CI gate * test(llm): make safety-marked assert formatting-stable
* fix(llm): add stop_sequences parity for tool completions * refactor(web-openai): dedupe request builders and satisfy no-panics gate * test(llm): mark multiline assert with safety comment for CI gate * test(llm): make safety-marked assert formatting-stable
Summary
This closes the tool/completion parameter parity gap for
stop_sequences.What changed
stop_sequences: Option<Vec<String>>toToolCompletionRequest.with_stop_sequences(...)builder onToolCompletionRequest.strip_unsupported_tool_params()to stripstop_sequencesjust like completion requests.stop_sequencesthrough worker/orchestrator proxy DTOs for tool completions.stopvalues into tool completion requests in both streaming and non-streaming HTTP paths.bedrock: uses tool-request stop sequences in inference config.nearai_chat: serializesstopfor both completion and tool-completion requests.Tests
test_strip_unsupported_tool_params_strips_stop_sequencesCloses #872