Skip to content

fix: reconcile complete streamed reasoning items - #219

Merged
franciscojavierarceo merged 6 commits into
vllm-project:mainfrom
StevenWang-CY:fix-streamed-reasoning-reconciliation
Aug 28, 2026
Merged

fix: reconcile complete streamed reasoning items#219
franciscojavierarceo merged 6 commits into
vllm-project:mainfrom
StevenWang-CY:fix-streamed-reasoning-reconciliation

Conversation

@StevenWang-CY

@StevenWang-CY StevenWang-CY commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #152.

The streaming accumulator previously merged reasoning text and summary events into one unindexed buffer and did not reconcile reasoning response.output_item.done events. A streamed response could consequently omit completed content, summaries, encrypted_content, status, or a reasoning item whose added event was absent.

This change:

  • gives reasoning text and reasoning summary events distinct typed payloads with their output and part indexes;
  • constructs reasoning items through ReasoningOutput::try_from for both added and done-only lifecycle events;
  • routes actual reasoning text and summary done events directly through ReasoningOutput::apply_done;
  • uses the complete reasoning item for every field it contains, including empty arrays and null values;
  • preserves content or summary collected from preceding part-done events when the complete item omits that array;
  • retains valid part-done state when a complete item is malformed;
  • verifies complete typed reasoning items survive the existing JSON storage round trip without leaking the private storage marker.

The Responses event contract defines reasoning done-event text as the full completed text. ResponseAccumulator therefore owns event lifecycle routing without retaining another reasoning content model or reconstructing terminal fields from deltas. No database schema or migration changes are required.

Test Plan

  • cargo test -p agentic-server-core reasoning_output_ — 3 passed
  • cargo test -p agentic-server-core reasoning_done_text_is_authoritative_even_when_empty — 1 passed
  • cargo test -p agentic-server-core executor::accumulator — 54 passed
  • cargo test -p agentic-server-core --test event_normalizer_test — 40 passed
  • cargo test -p agentic-server-core storage — 69 passed; 3 PostgreSQL environment tests ignored
  • cargo test -p agentic-server-core — passed
  • cargo test --workspace -- --test-threads=8 — passed
  • cargo clippy --workspace --all-targets -- -D warnings — passed
  • cargo fmt --all -- --check — passed
  • uvx pre-commit==4.4.0 run --all-files — passed

Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
Comment thread crates/agentic-server-core/src/executor/accumulator.rs Outdated
Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
Comment thread crates/agentic-server-core/src/executor/accumulator.rs Outdated
Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
Comment thread crates/agentic-server-core/src/executor/accumulator.rs Outdated
Comment thread crates/agentic-server-core/src/executor/accumulator.rs Outdated
Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
@franciscojavierarceo
franciscojavierarceo requested a lite review from Copilot August 28, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR fixes streamed reasoning item reconciliation so completed response.output_item.done reasoning items reliably override/merge partial streamed state, while keeping indexed reasoning text and summary parts distinct and preserving correct ordering and storage round-trips.

Changes:

  • Introduces typed, indexed reasoning text/summary payloads and updates SSE normalization + tests accordingly.
  • Updates ReasoningOutput to build from both OutputItemAdded and OutputItemDone, apply indexed done events, and reconcile completed items as authoritative.
  • Refactors ResponseAccumulator to route reasoning lifecycle events without maintaining a second reasoning text model; adds new accumulator tests for reconciliation scenarios.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/agentic-server-core/tests/event_normalizer_test.rs Updates tests to assert the new typed/indexed reasoning payload variants.
crates/agentic-server-core/src/types/io/output.rs Adds nullable-vec deserialization, builds ReasoningOutput from done items, applies indexed done parts, and reconciles completed items.
crates/agentic-server-core/src/storage/models/item.rs Strengthens storage round-trip test to ensure storage marker is stripped and fields survive.
crates/agentic-server-core/src/executor/accumulator.rs Refactors reasoning in-flight handling and completion reconciliation; adds multiple reasoning streaming tests.
crates/agentic-server-core/src/events/types.rs Splits reasoning payloads into distinct text vs summary delta/done variants with indexes.
crates/agentic-server-core/src/events/normalize.rs Parses the new reasoning payload variants from SSE JSON.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/agentic-server-core/src/executor/accumulator.rs
Comment thread crates/agentic-server-core/src/executor/accumulator.rs
Comment thread crates/agentic-server-core/src/executor/accumulator.rs
Comment thread crates/agentic-server-core/src/types/io/output.rs
Comment thread crates/agentic-server-core/src/types/io/output.rs
Signed-off-by: StevenWang-CY <203932027+StevenWang-CY@users.noreply.github.com>
@StevenWang-CY
StevenWang-CY force-pushed the fix-streamed-reasoning-reconciliation branch from 50b95ad to dab479f Compare August 28, 2026 16:49
@StevenWang-CY

Copy link
Copy Markdown
Contributor Author

@franciscojavierarceo Thanks for requesting the additional review. I audited all five findings against the Responses event lifecycle. Three identified the same stale-text fallback inconsistency; it is fixed in dab479f with regression coverage. The indexed-order and optional-field suggestions were addressed in their threads without adding conflicting lifecycle state, and all review threads are now resolved. The exact head passes the full workspace suite, focused tests, Clippy, formatting, and pre-commit. The refreshed repository CI jobs are currently queued, and I will follow through on any actionable result.

@StevenWang-CY

Copy link
Copy Markdown
Contributor Author

@franciscojavierarceo The refreshed head is now green across all nine repository checks, remains approved and cleanly mergeable against current main, and all review threads are resolved. When convenient, could you merge this PR? I will continue monitoring for any follow-up.

@franciscojavierarceo
franciscojavierarceo merged commit d8720a7 into vllm-project:main Aug 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reasoning retention 1/2] Reconcile complete streamed reasoning items

4 participants