Skip to content

Python: [Bug]: "type": "response.reasoning_text.delta" and "response.reasoning_text.done" both get exposed as "text_reasoning" #5157

@kostiak

Description

@kostiak

Description

I'm trying to use ag-ui to stream reasoning content. I noticed that after the deltas are streamed - I get another "delta" with the full content.

Tracing the issue I found ag-ui relies on "text_reasoning":

if content_type == "text_reasoning":
return _emit_text_reasoning(content, flow)

Looking at openai chat client - both delta and done call Content.from_text_reasoning:

case "response.reasoning_text.done":
contents.append(
Content.from_text_reasoning(
id=event.item_id,
text=event.text,
raw_representation=event,
)
)
metadata.update(self._get_metadata_from_response(event))
case "response.reasoning_summary_text.delta":
contents.append(
Content.from_text_reasoning(
id=event.item_id,
text=event.delta,
raw_representation=event,
)
)

Which (according to line 615) assigns both to "text_reasoning"

@classmethod
def from_text_reasoning(
cls: type[ContentT],
*,
id: str | None = None,
text: str | None = None,
protected_data: str | None = None,
annotations: Sequence[Annotation] | None = None,
additional_properties: MutableMapping[str, Any] | None = None,
raw_representation: Any = None,
) -> ContentT:
"""Create text reasoning content."""
return cls(
"text_reasoning",
id=id,
text=text,
protected_data=protected_data,
annotations=annotations,
additional_properties=additional_properties,
raw_representation=raw_representation,
)

Using the core framework I could look at the raw_representation to distinguish "delta" from "done" - is there a way to do that in ag-ui?

In general, wouldn't it be better to separate those two events? Maybe "text_reasoning_delta" and "text_reasoning_done" - or alternatively decide that one of them is "text_reasoning" and the other has a prefix/postfix?

Of course I might be missing something and there might be a cleaner way to do this with ag-ui that I'm missing.

Thanks in advance.

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework-core 1.0.0 and agent-framework-ag-ui 1.0.0

Python Version

Python 3.13

Additional Context

No response

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions