Skip to content

Conversation

@tlipoca9
Copy link
Contributor

@tlipoca9 tlipoca9 commented Sep 10, 2025

Purpose

Fixes #24509

Description

The issue was that delta_text was being added twice when tool_choice was set to 'required'.

Signed-off-by: tlipoca9 <[email protected]>

Signed-off-by: tlipoca9 <[email protected]>
@tlipoca9 tlipoca9 requested a review from aarnphm as a code owner September 10, 2025 11:28
@mergify mergify bot added the frontend label Sep 10, 2025
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 addresses a bug where delta_text was being added twice when tool_choice was set to 'required' during streaming chat completions. The change correctly removes a redundant update to previous_texts that was causing this duplication. The fix is sound and also improves code clarity by handling the update of previous_texts in a single, consistent location at the end of the loop.

Copy link
Collaborator

@chaunceyjiang chaunceyjiang left a comment

Choose a reason for hiding this comment

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

Can you add an e2e test?

Signed-off-by: tlipoca9 <[email protected]>
@tlipoca9 tlipoca9 marked this pull request as draft September 11, 2025 11:39
Signed-off-by: tlipoca9 <[email protected]>
Signed-off-by: tlipoca9 <[email protected]>
@chaunceyjiang
Copy link
Collaborator

There is already a PR fixing this issue.

#23312

assert serving_completion.chat_template == CHAT_TEMPLATE

@pytest.mark.asyncio
async def test_serving_chat_tool_choice_required_streaming():
Copy link
Collaborator

Choose a reason for hiding this comment

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

E2E is also what we need, and we can keep moving forward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll try to get this done.

@tlipoca9 tlipoca9 closed this Sep 15, 2025
@tlipoca9 tlipoca9 reopened this Sep 15, 2025
@tlipoca9 tlipoca9 changed the title [Bugfix] Prevent duplicate delta_text addition when tool_choice is 'required' [Chore] Add E2E test for 'required' tool_choice with streaming Sep 15, 2025
Signed-off-by: tlipoca9 <[email protected]>
Signed-off-by: tlipoca9 <[email protected]>
@mergify
Copy link

mergify bot commented Sep 16, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @tlipoca9.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Sep 16, 2025
@mergify mergify bot removed the needs-rebase label Sep 16, 2025
@tlipoca9 tlipoca9 marked this pull request as ready for review September 16, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug]: Tool call fails with streaming enabled and tool_choice "required"

2 participants