autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add Support for Mixed Messages Containing Both tool_call and Text from ChatCompletionClient

Open zjsxply opened this issue 1 year ago • 3 comments

What feature would you like to be added?

The ChatCompletionCache should support messages that contain both tool_call and text (content) fields simultaneously. Currently, the implementation raises warnings and defaults to processing only tool_call, ignoring the content field. This is limiting and does not align with the behavior of certain models, such as gpt-4o, which can naturally return mixed messages.

/data/xxx/anaconda3/envs/apr/lib/python3.13/site-packages/autogen_ext/models/cache/_chat_completion_cache.py:132: UserWarning: Both tool_calls and content are present in the message. This is unexpected. content will be ignored, tool_calls will be used.
  result = await self.client.create(

For example, a tool_call might include instructions to invoke a tool, and the content field could provide supplemental context or fallback output, both of which are important for downstream applications.

The desired feature should allow a single message to contain both tool_call and content fields without raising warnings or dropping data.

Why is this needed?

Models such as gpt-4o are designed to return mixed messages. Ignoring part of the response reduces the utility of these models and misaligns with their intended behavior.

zjsxply avatar Jan 23 '25 06:01 zjsxply

The warning comes from the openai client. Though the issue is more general, the CreateResult field current doesn't allow both text and tool call in the same result.

@jackgerrits Something we need to fix.

ekzhu avatar Jan 23 '25 09:01 ekzhu

Hi @ekzhu , any update on this? due to this issue, I am not getting the flow correct in our application.

amanG251314 avatar Feb 18 '25 06:02 amanG251314

@amanG251314 yes there is an PR for this #5500 , could you please try it out?

ekzhu avatar Feb 18 '25 14:02 ekzhu