Skip to content

Conversation

@Mr-Righter
Copy link

Problem

For some LLM providers (e.g., Volcengine's doubao-seed models), when the model returns a function call response with thinking/reasoning content, the thinking content is stored in choice.message.model_extra.get("reasoning_content") instead of choice.message.content.

The current implementation only checked choice.message.content for thinking content in tool call responses, which caused the ThoughtEvent to be missing when using these providers.

Solution

In the create method of BaseOpenAIChatCompletionClient, when handling tool call responses, prioritize checking reasoning_content from model_extra before falling back to message.content. This is consistent with the existing behavior for non-tool-call responses and the create_stream method.

Test Code

from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_core.models import ModelInfo
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console

model_info = ModelInfo(
    vision=True,
    function_calling=True,
    json_output=True,
    family="seed",
    structured_output=True,
)
client = OpenAIChatCompletionClient(
    model="doubao-seed-1-8-251215",
    model_info=model_info,
    extra_body={"thinking": {"type": "enabled"}},
)

async def web_search(query: str) -> str:
    """Find information from the web."""
    return "AutoGen is a programming framework for building multi-agent applications."

agent = AssistantAgent(
    name="assistant",
    model_client=client,
    tools=[web_search],
    reflect_on_tool_use=False,
    max_tool_iterations=1
)

await Console(
    agent.run_stream(
        task="Explain what AutoGen is and its features.",
    )
)

Results

Before this fix

---------- TextMessage (user) ----------
Explain what AutoGen is and its features.
---------- ToolCallRequestEvent (assistant) ----------
[FunctionCall(id='call_0m1gpz63zy6cyavmnl8o3v94', arguments=' {"query": "AutoGen definition and key features"}', name='web_search')]
---------- ToolCallExecutionEvent (assistant) ----------
[FunctionExecutionResult(content='AutoGen is a programming framework for building multi-agent applications.', name='web_search', call_id='call_0m1gpz63zy6cyavmnl8o3v94', is_error=False)]
---------- ToolCallSummaryMessage (assistant) ----------
AutoGen is a programming framework for building multi-agent applications.

After this fix

---------- TextMessage (user) ----------
Explain what AutoGen is and its features.
---------- ThoughtEvent (assistant) ----------
Got it, let's tackle this question about AutoGen. First, I need to remember what AutoGen is, but wait, maybe I should use web search to get the latest and most accurate info, especially since it's a tool that's evolving. Let me start by searching for "AutoGen definition and features" to get the official details from Microsoft.
---------- ToolCallRequestEvent (assistant) ----------
[FunctionCall(id='call_b55s8k8ccjfq03jr6py4ggca', arguments=' {"query": "AutoGen definition and key features"}', name='web_search')]
---------- ToolCallExecutionEvent (assistant) ----------
[FunctionExecutionResult(content='AutoGen is a programming framework for building multi-agent applications.', name='web_search', call_id='call_b55s8k8ccjfq03jr6py4ggca', is_error=False)]
---------- ToolCallSummaryMessage (assistant) ----------
AutoGen is a programming framework for building multi-agent applications.

@Mr-Righter Mr-Righter marked this pull request as draft December 19, 2025 13:41
@Mr-Righter Mr-Righter marked this pull request as ready for review December 19, 2025 13:42
@Mr-Righter Mr-Righter marked this pull request as draft December 19, 2025 13:42
@Mr-Righter Mr-Righter marked this pull request as ready for review December 19, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant