Skip to content

[router][grpc] Fix inconsistent behavior of conversation_id not found#12299

Merged
slin1237 merged 3 commits intomainfrom
chang/resp-conv
Oct 28, 2025
Merged

[router][grpc] Fix inconsistent behavior of conversation_id not found#12299
slin1237 merged 3 commits intomainfrom
chang/resp-conv

Conversation

@CatherineSue
Copy link
Collaborator

@CatherineSue CatherineSue commented Oct 28, 2025

Motivation

The current responses/handler.rs tries to create a conversation when the request contains a conversation id that is not found. The correct behavior is to throw a not found error.

Screenshot 2025-10-28 at 7 12 32 PM

OpenAI also checks for the conversation id format first.

Screenshot 2025-10-28 at 7 13 05 PM

Modifications

  • Add Validate derive to protocols/responses.rs
  • Add validate_conversation_id to validate conversation id.
  • Add tests
  • Replace conversation logic to a BadRequestError when a conversation id is invalid

Accuracy Tests

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @CatherineSue, 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 refines the handling of conversation_id in the gRPC router. Previously, the system would implicitly create a new conversation if a provided conversation_id did not exist. This change aligns the system's behavior with common API practices, such as OpenAI's, by enforcing strict validation on conversation_id format and requiring explicit creation of conversations. Now, requests with invalidly formatted or non-existent conversation IDs will result in a BadRequestError, providing clearer feedback to the user and preventing unintended conversation creation.

Highlights

  • Conversation ID Validation: Implemented strict validation for conversation_id to ensure it adheres to a specific format (alphanumeric, underscores, or dashes), aligning with common API practices like OpenAI's.
  • Behavior Change for Missing Conversation IDs: Modified the system's behavior so that providing a non-existent conversation_id now results in a BadRequestError instead of implicitly creating a new conversation. Users are now required to explicitly create conversations.
  • Early Validation in gRPC Handler: Integrated the new validation logic into the gRPC responses handler, allowing for early detection and rejection of requests with invalid or non-existent conversation IDs.
  • Comprehensive Unit Tests: Added a new test module with extensive unit tests to cover various scenarios for conversation ID validation, including valid, invalid, and missing IDs, and to verify the exact error message format.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses the issue of inconsistent behavior when a conversation_id is not found. By introducing validation for the conversation_id format and changing the logic to return an error instead of creating a new conversation, the behavior is now more predictable and aligned with user expectations. The addition of comprehensive unit tests is also a great contribution to ensure the new logic is robust. I've provided a couple of suggestions to improve code clarity and maintainability.

@slin1237 slin1237 merged commit b48354c into main Oct 28, 2025
30 of 33 checks passed
@slin1237 slin1237 deleted the chang/resp-conv branch October 28, 2025 23:24
@slin1237 slin1237 mentioned this pull request Oct 30, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments