Problem/Motivation
If a single Converse message contains multiple tool use requests, the following user message must contain a tool use response for each use call in the previous request. The responses cannot be broken up over multiple messages, which is what is currently happening and results in an exception.
Steps to reproduce
Invoke an agent that will call multiple tools as part of the same assistant message.
Get an exception stating that tool with an ID was expected to have a response in the next user message.
Proposed resolution
If tools are requested to be used together in one message, the next message must have content that fulfills both tool requests.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3543203-7.patch | 1.65 KB | mediabounds |
Issue fork ai_provider_aws_bedrock-3543203
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lpeabody commentedBumping to major since it can result in an exception that is not easy to trace.
Comment #4
lpeabody commentedI added an initial stab at grouping required tool responses into the next message. I don't think this is a great implementation FWIW. Not sure of a better way to go about it for now (I just needed to get it working).
Comment #5
mediabounds commentedI encountered the same issue (particularly when working with the Amazon Nova Pro model); I came up with a smaller patch that just assumes that if there are multiple tool messages in a row in the input that they should all be sent to amazon in one message.
This definitely feels like a hack and is simply working around the assumption made in the base AI module that a `ChatMessage` can only have one set of tool results.
Comment #6
mediabounds commentedRe-rolling my patch against the 1.1.x branch.
Comment #7
mediabounds commentedFixing an issue in my previous patch where it could attempt to combine a tool response with an assistant response.
Comment #8
driskell commentedI get this too. Thanks for looking into a patch!
@mediabounds I think it’s safe to say if there’s multiple tool use together they can be merged. I can’t think of any case where a tool use response would appear consecutively if the previous assistant request(s) didn’t ask for multiple.
Comment #9
marcus_johansson commentedSorry for not picking this up sooner, the MR looks good and it has been tested by a colleague of mine. Getting merged. Thank you everyone
Comment #10
marcus_johansson commented