fix: validate Messages terminal event ordering by franciscojavierarceo · Pull Request #402 · vllm-project/agentic-api · GitHub
Skip to content

fix: validate Messages terminal event ordering - #402

Draft
franciscojavierarceo wants to merge 1 commit into
mainfrom
codex/messages-terminal-order
Draft

franciscojavierarceo wants to merge 1 commit into
mainfrom
codex/messages-terminal-order

Conversation

@franciscojavierarceo

@franciscojavierarceo franciscojavierarceo commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Reject Messages streams that interleave content blocks with terminal message deltas. A message_delta while a block is open, or a new block after a message delta, now produces a fixed api_error before tool dispatch or successful completion. Previously, these invalid sequences could still execute a search.

This follows the Messages streaming event flow: content blocks precede one or more message deltas. Repeated cumulative usage snapshots remain valid. The existing ingestion path and per-round state own both checks.

Part of #313 and Enterprise Readiness #316; follow-up to #396. Full schema validation and retained-resource limits remain open.

Test Plan

  • Regression failed before the fix with an unexpected search request. Covers a message delta before content and during an open block in both recorded rounds.
  • Repeated-terminal-snapshot control preserves one public lifecycle and unchanged cumulative usage. Existing open-block test now omits message deltas to continue exercising the message-stop gate directly.
  • Core library on current main: 1,068 passed, 5 ignored. Messages stream integration: 28 passed, including the merged payload/identifier and extension-delivery regressions from fix: validate Messages block payloads before assembly #411.
  • Workspace all-target Clippy with warnings denied, formatting, diff check and all-files pre-commit checks passed.
  • Deterministic local servers and existing recordings; no live inference.

Reconciled with main after #411 merged. Retains all merged validation and extension-delivery assertions; the terminal-order guards are unchanged.

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.

Copilot review overview

🟢 Approval recommended

The focused validation changes match the documented protocol and include adequate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Enforces valid terminal ordering in Messages streams to prevent malformed rounds from dispatching tools or completing successfully.

Changes:

  • Rejects message_delta while content blocks remain open.
  • Rejects new content blocks after terminal deltas.
  • Adds regression coverage and documents repeated usage snapshot behavior.
File Description
docs/​design/​claude-code-integration.md Documents terminal event ordering.
crates/​agentic-server-core/​tests/​messages_stream_test.rs Tests invalid interleaving and repeated snapshots.
crates/​agentic-server-core/​src/​executor/​messages_stream/​ingestion.rs Adds lifecycle validation guards.

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

Signed-off-by: Francisco Javier Arceo <arceofrancisco@gmail.com>
@franciscojavierarceo
franciscojavierarceo force-pushed the codex/messages-terminal-order branch from 043700c to 54faf0c Compare October 9, 2026 00:39

This branch has not been deployed

No deployments
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.

2 participants