Skip to content

PyAutoGen Reasoning Content #7410

@pccidaos

Description

@pccidaos

What happened?

Upstream Issue: PyAutoGen Reasoning Content

Repository: https://github.com/microsoft/autogen

Title: OpenAIClient.message_retrieval does not handle list content from reasoning models (gpt-5, o1)


Body (copy below)

Description

When using OpenAI-compatible APIs with reasoning models (gpt-5, o1), the Chat Completions API returns message.content as a list of content blocks, e.g.:

[
  {"type": "reasoning", "text": "..."},
  {"type": "text", "text": "actual response"}
]

OpenAIClient.message_retrieval returns this list unchanged. Downstream code in _generate_oai_reply_from_client uses extract_text_or_completion_object(response)[0], which yields the raw list. Callers expect a string or completion object, leading to empty or malformed responses.

Environment

  • pyautogen 0.2.35
  • OpenAI API with gpt-5 deployment

Expected Behavior

message_retrieval should normalize list content to a string by extracting text from blocks with type == "text" (or "output_text").

Suggested Fix

In OpenAIClient.message_retrieval, when choice.message.content is a list, concatenate text from blocks with type in ("text", "output_text") and return that string instead of the raw list.

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

Python dev (main branch)

Other library version.

pyautogen 0.2.35

Model used

gpt-5

Model provider

OpenAI

Other model provider

No response

Python version

3.11

.NET version

None

Operating system

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions