Skip to content

fix: include final reasoning in run events - #60664

Closed
itsflownium wants to merge 1 commit into
NousResearch:mainfrom
itsflownium:fix/runs-sse-reasoning-parity-60634
Closed

fix: include final reasoning in run events#60664
itsflownium wants to merge 1 commit into
NousResearch:mainfrom
itsflownium:fix/runs-sse-reasoning-parity-60634

Conversation

@itsflownium

Copy link
Copy Markdown
Contributor

Summary

  • Extract current-turn reasoning fields from completed run results.
  • Emit a final reasoning.available event sourced from the completed result when richer reasoning exists.
  • Include the same structured reasoning payload on run.completed and pollable run status.

Problem
The live /v1/runs/{run_id}/events stream only forwarded reasoning progress callback previews. Those previews could be empty or answer-like, while the final session messages preserved richer reasoning, reasoning_content, and reasoning_details, so clients rendered different reasoning before and after refresh.

Validation

  • pytest -q tests/gateway/test_api_server_runs.py::TestRunEvents::test_events_stream_returns_completed tests/gateway/test_api_server_runs.py::TestRunEvents::test_events_stream_exposes_final_reasoning_payload
  • pytest -q tests/gateway/test_api_server_runs.py
  • python -m py_compile gateway/platforms/api_server.py tests/gateway/test_api_server_runs.py
  • python -m ruff check gateway/platforms/api_server.py tests/gateway/test_api_server_runs.py

Fixes #60634

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels Jul 8, 2026
@teknium1

teknium1 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thanks — the premise checks out (provider-native final reasoning from turn_finalizer.last_reasoning is never surfaced to /v1/runs consumers; only the mid-run 500-char content preview fires), and the implementation is defensive and tested.

Closing this iteration on payload-shape grounds rather than direction:

  1. The full uncapped reasoning is emitted three times — the final reasoning.available SSE event, run.completed, AND the persisted run status — versus the 500-char cap the mid-run events honor. On long reasoning traces that bloats status storage and SSE payloads.
  2. The new-schema reasoning.available (adds source + reasoning* keys) gives consumers two different event shapes for the same event name.

A follow-up that caps/deduplicates (e.g. full reasoning in ONE place — probably run.completed — with the event keeping the preview convention) would be very mergeable. The extraction helper itself is good; feel free to reuse it as-is in the rework.

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runs SSE exposes incomplete reasoning compared with session history raw messages

3 participants