You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering a BadRequestError while using MessageHistoryLimiter for context management in a multi-agent GroupChat setup. Below is the error message:
BadRequestError: Error code: 400 - {'error': {'message': "Invalid parameter: messages with role 'tool' must be a response to a preceeding message with 'tool_calls'.", 'type': 'invalid_request_error', 'param': 'messages.[1].role', 'code': None}}
Context
Context:
I am using a GroupChat of multiple agents where each agent performs specific tasks, including scraping content from a URL and processing it into structured data. The workflow involves passing tasks between agents and calling registered functions (tools). I implemented the MessageHistoryLimiter to manage context within this chat environment, but the error consistently occurs during the workflow.
The error seems to occur when an agent sends a message with a tool role, but the system expects a tool_calls entry to precede it.
The issue likely stems from the context management changes introduced with MessageHistoryLimiter, which may have affected the sequence of tool-related messages.
I have registered the tools with the register_function:
hmm currently message history limiter doesn't account for that behavior.
I think the fix here is to add a check if the transform violates this rule, e.g. 'tools' must be preceded by tool calls. I suspect this error can also show up in other transforms. One solution could be to create a new transform _DropBadMesages or _DropViolatingMessages that the other transforms could use internally. lmk what you guys think.
Describe the issue
Error
I am encountering a BadRequestError while using MessageHistoryLimiter for context management in a multi-agent GroupChat setup. Below is the error message:
Context
Context:
I am using a GroupChat of multiple agents where each agent performs specific tasks, including scraping content from a URL and processing it into structured data. The workflow involves passing tasks between agents and calling registered functions (tools). I implemented the MessageHistoryLimiter to manage context within this chat environment, but the error consistently occurs during the workflow.
The error seems to occur when an agent sends a message with a tool role, but the system expects a tool_calls entry to precede it.
The issue likely stems from the context management changes introduced with MessageHistoryLimiter, which may have affected the sequence of tool-related messages.
I have registered the tools with the register_function:
And i create assistant functions like this:
And there is one agent that executes the tools and others that call that agent.
I have created a custom_speaker_selection_funct that i use like this:
And then i start with initiate_chat
Example
I leave here an example of my chat_history but without the content. I can ensure that every tool is preceeded by a valid tool call.
Role: user
Name: collector
Content:
Role: assistant
Name: finder
Content:
Tool Calls:
Tool ID: CALL_ID
Tool Name: TOOL_NAME
Tool Arguments: ARGS
Role: tool
Name: coder
Content:
Role: assistant
Name: reader
Content:
Tool Calls:
Tool ID: CALL_ID
Tool Name: TOOL_NAME
Tool Arguments: ARGS
Role: tool
Name: coder
Content:
Steps to reproduce
Screenshots and logs
No response
Additional Information
autogen 0.3.0
pyautogen 0.2.31
The text was updated successfully, but these errors were encountered: