Skip to content

fix(api-server): stream run reasoning deltas - #67339

Draft
xingj404-lab wants to merge 1 commit into
NousResearch:mainfrom
xingj404-lab:codex/stream-runs-reasoning-deltas
Draft

fix(api-server): stream run reasoning deltas#67339
xingj404-lab wants to merge 1 commit into
NousResearch:mainfrom
xingj404-lab:codex/stream-runs-reasoning-deltas

Conversation

@xingj404-lab

Copy link
Copy Markdown

Summary

  • wire the agent reasoning callback into the /v1/runs execution path
  • emit additive reasoning.delta SSE events for structured reasoning chunks
  • preserve the existing message, tool, error, and completion event behavior
  • add regression coverage proving reasoning frames arrive before run.completed

Root cause

The provider stream already invokes the agent's reasoning callback, but the API server's runs adapter did not pass such a callback when constructing AIAgent. As a result, reasoning could be persisted and visible in session history after the run while remaining absent from the live runs SSE stream.

Compatibility

This is an additive SSE event. Existing clients that ignore unknown event types continue to behave as before.

Validation

  • scripts/run_tests.sh tests/gateway/test_api_server_runs.py
  • 34 tests passed

Fixes #60634

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #15169: the live patch uses the same /v1/runs reasoning-callback wiring and reasoning.delta SSE mechanism.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression coverage. The underlying gap is real on current main: gateway/platforms/api_server.py:1705-1834 does not pass a reasoning callback into AIAgent, while run_agent.py:5037-5049 only delivers reasoning chunks through self.reasoning_callback.

Problems

Suggested changes

  • Consolidate on one canonical patch and settle the wire shape before salvage, preserving the earlier contribution where feasible.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/streaming Streaming responses: gateway delivery, provider wire labels Jul 19, 2026
@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown

This was generated by AI during triage.

Summary

Twenty-six PRs address or reference this issue complex across four causes: incorrect answer-derived reasoning snapshots, missing live reasoning callbacks in Runs/Chat/Responses SSE, provider-specific reasoning-marker leakage, and an upstream LLM Gateway SSE parsing failure. The diffs either correct the reasoning source, wire structured reasoning to API transports, add delimiter scrubbers, or introduce a JSONDecodeError fallback; several combine or supersede those narrower changes.

Related pull requests

Duplicates

Runs live-delta cluster: #15169, #55163, #61259, and #67339, with the same callback mechanism also included in broader #75562; Chat callback cluster: #11482, #13401, #22364, #35083, #52606, and the Chat portions of #57094/#75562. Reasoning-source duplicates are #24566/#24571 and the corresponding parts of #24535/#24852/#75562; Chinese-marker scrubbers are #43836/#43839/#43932; JSONDecodeError fallbacks are #24572/#24852.

Suggested consolidation

Close #67339 as a duplicate of #15169: despite the keep-open review and recorded best-fix verdict on #67339, its diff implements the same Runs callback and reasoning.delta path as the earlier #15169, which is itself a recorded best fix, while differing only in the unsettled delta versus text payload key. Author action on #15169: rebase onto current main, use the active-stream guard, settle and document the payload schema, and correct the review-identified error-path test; keep #60906 open for complementary final-history reconciliation, keep #75562 open only as a salvage path for the distinct answer-echo removal and Chat transport work, and consolidate the remaining live Runs and Chat duplicates into those canonical scopes.

Complex graph

flowchart TD
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    I24518(["issue #24518 (closed)"])
    I60634(["issue #60634 (open)"])
    subgraph Dup15169 ["PRs duplicating each other"]
        P15169["PR #15169 (open)"]
        P24535["PR #24535 (closed)"]
        P55163["PR #55163 (open)"]
        P61259["PR #61259 (open)"]
        P67339["PR #67339 (open)"]
        P75562["PR #75562 (open)"]
    end
    P67339 -.->|partial| I24518
    P67339 -->|best fix| I60634
    class I24518 closed
    class I60634 open
    class P15169 open
    class P24535 closed
    class P55163 open
    class P61259 open
    class P67339 open
    class P75562 open
    class P15169 best
    class P24535 best
    class P67339 best
    class P75562 best
    class P75562 best
    class P67339 target
    click I24518 "https://github.com/NousResearch/hermes-agent/issues/24518"
    click I60634 "https://github.com/NousResearch/hermes-agent/issues/60634"
    click P15169 "https://github.com/NousResearch/hermes-agent/pull/15169"
    click P24535 "https://github.com/NousResearch/hermes-agent/pull/24535"
    click P55163 "https://github.com/NousResearch/hermes-agent/pull/55163"
    click P61259 "https://github.com/NousResearch/hermes-agent/pull/61259"
    click P67339 "https://github.com/NousResearch/hermes-agent/pull/67339"
    click P75562 "https://github.com/NousResearch/hermes-agent/pull/75562"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).

Cross-PR triage: Reviewed 26 pull requests and 5 issues in this complex. Each diff was read against this issue; Assessment working set: 230 kB of PR diffs, 89 kB of issue/PR text, 42 kB of discussion (64 comments), 40 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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

Labels

area/streaming Streaming responses: gateway delivery, provider wire comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runs SSE exposes incomplete reasoning compared with session history raw messages

4 participants