-
Notifications
You must be signed in to change notification settings - Fork 322
Description
Problem Statement
I'm hooking into AfterToolInvocationEvent and changing the tool output text to "USER INTERACTION REQUIRED: DO NOT RESPOND FURTHER UNTIL THE USER RESPONDS."
I then use the tool input for something and wait for the user to respond to my output. What i'm attempting to achieve is not possible with the user_handoff tool in it's current form.
The model as instructed does not respond and the last message in agent.messages contains:
{'role': 'assistant', 'content': []}
When the user responds next the agent throws the following error:
Error: An error occurred (ValidationException) when calling the ConverseStream operation: The content field in the Message object at messages.5 is empty. Add a ContentBlock object to the content field and try again.
If i instead change the tool output text to: "USER INTERACTION REQUIRED: RESPOND ONLY WITH A FULL STOP (.) TO CONTINUE. DO NOT EXECUTE THE TOOL AGAIN." The model will now respond to the tool request with a single full stop as seen in agent.messages:
{'role': 'assistant', 'content': [{'text': '.'}]}
With the full stop in place the user can now respond as the message content is not empty.
Proposed Solution
A few options?
- Allow the model to respond with an empty string and record it as such in agent.messages, as the model had intended
- Add a function to force responses on behalf of an agent, for example agent.response.force("message") which would output to the user and be recorded in agent.messages as part of the conversation history.
3. Add a function to force_stop responses, so if the agent calls a tool we can stop any further responses from the model and handle any response manually (in combination with a forced manual output). Of which would be recorded in agent.messages.Perhaps i should be using tool "stop" perhaps in a workflow - i'll test
Use Case
To facilitate structured_output as part of a streaming response.
Alternatives Solutions
No response
Additional Context
No response