-
Notifications
You must be signed in to change notification settings - Fork 156
[BUG] Agent Framework: Handle model response when toolUse is not accompanied by text #3755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ylwu-amzn
merged 2 commits into
opensearch-project:main
from
pyek-bot:bug_fix_no_text_with_tooluse
Apr 26, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it easier just to check if LLM_RESPONSE_FILTER in parameters.keys then get the response, else you read from the TOOL_CALLS_PATH? this exception is not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of the keys will be present in the map for all models supporting function calling:
LLM_RESPONSE_FILTER
points to where we can fetch thetext
returned by the model. Once we fetch the text, the logic checks for whether there is a toolUse block after or not.TOOL_CALLS_PATH
points to where we can fetch atoolUse
block returned by the model.For example, these are values for
claude
LLM_RESPONSE_FILTER: $.choices[0].message.content
TOOL_CALLS_PATH: $.choices[0].message.tool_calls
Before this fix, we would always look for
LLM_RESPONSE_FILTER
and in the case of this payload:It would lead to an error since there is no text field. Therefore, we then check for
toolUse
path. This is required as different models have a different response format. A better way to handle this would be to first check for a parent path like$.choices[0].message
which might contain both the text and toolUse as children. However, this is not guaranteed as the response heavily depends on the model. Hence, the try-catch.