Repository navigation
fix(models): keep text sent alongside a function response in ApigeeLlm - #7476
Closed
AkshayShah03 wants to merge 1 commit into
Closed
AkshayShah03 wants to merge 1 commit into
AkshayShah03 wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Contributor
Author
|
@googlebot I signed it! |
In the Chat Completions path, _content_to_messages returned only the tool messages (plus tool-attached media) when a Content held a function_response, silently dropping any text or media parts sent with it. Those parts now follow the tool messages in a single user message, matching LiteLlm. Fixes google#7475
AkshayShah03
force-pushed
the
fix/apigee-text-with-function-response
branch
from
October 9, 2026 12:07
3d76ae5 to
ef816e3
Compare
Collaborator
|
Thank you @AkshayShah03 for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit f5db310. Closing this PR as the changes are now in the main branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
In the Chat Completions path of
ApigeeLlm,CompletionsHTTPClient._content_to_messagesreturned early when aContentheld afunction_response, emitting only the tool messages (plus any tool-attached media). Text or media parts sent in the sameContentwere collected intocontent_partsbut never used, so they were silently dropped from the request.Solution:
A tool-role message carries only the tool result, so the remaining parts now follow the tool messages in a single user message, together with any tool-attached media (media first, then the other parts). A lone text part collapses to a plain string, matching the non-tool branch. This mirrors how
LiteLlmalready handles the same case (_content_to_message_paramsends leftover parts as a follow-up message).Testing Plan
Unit Tests:
Added to
tests/unittests/models/test_apigee_llm.py:test_content_conversion_keeps_text_alongside_function_response: function response + text → tool message, then{"role": "user", "content": "<text>"}.test_content_conversion_keeps_text_alongside_function_response_media: function response with attached image + text → tool message, then one user message with the image and the text.Both fail on
mainand pass with this change. The existing media-only and no-media tests are unchanged and still pass.pyinkandisortreport no changes.Manual End-to-End (E2E) Tests:
Not run against a live Apigee / OpenAI-compatible backend. The reproduction snippet from #7475 prints only the tool message on
mainand the tool message followed by the user text message with this change.Checklist