Skip to content

[fix] Stream OpenAILike reasoning deltas as native events - #8552

Closed
fengjikui wants to merge 1 commit into
agno-agi:mainfrom
fengjikui:codex/openai-like-reasoning-delta
Closed

fengjikui wants to merge 1 commit into
agno-agi:mainfrom
fengjikui:codex/openai-like-reasoning-delta

Conversation

@fengjikui

Copy link
Copy Markdown
Contributor

Summary

Fixes #8400 by routing streaming model chunks that contain reasoning_content or redacted_reasoning_content through Agno's native reasoning event pipeline when stream_events=True.

On current main, a model stream chunk with only reasoning_content updates run_response.reasoning_content, but it is emitted as a generic RunContent event. That means /runs and downstream /agui consumers do not receive ReasoningContentDelta / REASONING_MESSAGE_CONTENT events for OpenAI-compatible models that expose reasoning text in streaming chunks.

This PR emits ReasoningContentDelta for reasoning deltas during event streaming, while preserving the existing non-event-streaming behavior where reasoning content remains attached to the run content event.

Root cause

handle_model_response_chunk() already accumulates model_response_event.reasoning_content onto the run response, but the event emission branch treated reasoning-only chunks as ordinary run content. Native reasoning delta events were only emitted by provider-specific stream helpers, so OpenAILike chunks with reasoning_content did not enter the common reasoning event path.

Validation

Reproduced on current origin/main before the fix:

['RunContent']
run reasoning: thinking

Validation after rebasing onto current origin/main:

uv run --with-editable ./libs/agno --with pytest pytest libs/agno/tests/unit/reasoning/test_reasoning_streaming.py::test_model_stream_reasoning_chunk_emits_reasoning_delta_event libs/agno/tests/unit/reasoning/test_reasoning_streaming.py::test_model_stream_mixed_reasoning_and_content_emits_both_events -q
uv run --with-editable ./libs/agno --with pytest --with pytest-asyncio pytest libs/agno/tests/unit/reasoning/test_reasoning_streaming.py -q
uv run --with ruff ruff check libs/agno/agno/agent/_response.py libs/agno/tests/unit/reasoning/test_reasoning_streaming.py
uv run --with ruff ruff format --check libs/agno/agno/agent/_response.py libs/agno/tests/unit/reasoning/test_reasoning_streaming.py
git diff --check

AI assistance was used to prepare this patch; I reviewed the diff and validation evidence before opening the PR.

@fengjikui
fengjikui requested a review from a team as a code owner June 24, 2026 18:07
@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Possible duplicate: The following open PRs also reference the same issue(s):

If this is intentional, please explain in your PR description why this approach is preferred. Otherwise, consider collaborating on the existing PR instead.


This PR has been automatically closed. There is already an open PR addressing this issue. If you believe your contribution is valuable, please comment on the original issue explaining your approach and why it might be preferred. A maintainer can reopen this PR if appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] OpenAILike does not emit native reasoning events when streaming chunks include reasoning_content

1 participant