Skip to content

fix(messages): mark clean EOF without message_stop as failed - #576

Merged
franciscojavierarceo merged 3 commits into
vllm-project:mainfrom
justrightnow:fix/313-premature-eof-span
Nov 22, 2026
Merged

franciscojavierarceo merged 3 commits into
vllm-project:mainfrom
justrightnow:fix/313-premature-eof-span

Conversation

@justrightnow

Copy link
Copy Markdown
Contributor

Summary

Part of #313. On a premature HTTP EOF (no message_stop), the Messages stream already sends the client an event: error frame and no successful terminal (finish() refuses to synthesize one). However, messages_stream_body unconditionally called execution.completed_with_stop_reason(...), so the agentic.execute span was recorded as completed with Status::Unset — telemetry reported a successful turn the client never saw.

This adds record_terminal_outcome, which derives the span outcome from the same has_completed_round() gate finish() uses to emit the error:

  • completed round → keeps its stop-reason outcome (completed / incomplete);
  • no completed round (clean EOF) → failed with FailureCategory::Stream (error.type=stream, Status::Error), with delivery still delivered since the error frame reached the client.

This does not change client-visible frames or tool dispatch. The intentional max_tokens mid-call tolerance from #345 is untouched.

Test Plan

  • cargo fmt -- --check — passed.
  • cargo clippy --workspace --all-targets -- -D warnings — passed, 0 warnings.
  • cargo test -p agentic-server-core --test execution_trace_test messages_stream — 5 passed, including new messages_stream_clean_eof_without_message_stop_is_failed asserting the error frame plus a failed/error-status span with error.type=stream.
  • cargo test -p agentic-server-core --test messages_stream_test — 29 passed (existing EOF/incomplete-stream cases unchanged).
  • cargo test --workspace --no-fail-fast — all targets pass except two pre-existing environment-dependent tests (messages_returns_anthropic_error_for_unreachable_upstream and messages_gateway_loop_returns_anthropic_error_for_unreachable_upstream, expected 502 / got 504 on this host; reproduced on pristine origin/main, unrelated to this change).

On a premature HTTP EOF (no message_stop), the Messages stream already
sends the client an error frame and no successful terminal. However, the
agentic.execute span was unconditionally marked completed, so telemetry
reported a successful turn that the client never saw.

Add record_terminal_outcome to choose the span outcome from the same
has_completed_round() gate that finish() uses to emit the error: a completed
round keeps its stop-reason outcome; otherwise the execution is failed with
FailureCategory::Stream. This is part of vllm-project#313's requirement that an incomplete
Messages stream never appear successful.

Test: trace test asserting a clean EOF without message_stop yields an error
frame and a failed/error-status execution span with error.type=stream.

Signed-off-by: Jack Wei <[email protected]>
The previous fix pushed messages_stream.rs to 503 production lines,
three over the pre-commit rust-file-sizes limit of 500. Shorten the
record_terminal_outcome doc comment to one line so the file is back at 500
without changing behavior.

Signed-off-by: Jack Wei <[email protected]>
@franciscojavierarceo

Copy link
Copy Markdown
Collaborator

the clean-EOF path now marks agentic.execute as failed, but it still calls stage.finish(None) before checking has_completed_round(), so the inference stage is recorded as successful for the same incomplete upstream response. we should finish that stage with FailureCategory::Stream on clean EOF and assert its outcome alongside the execution span in the regression test.

@justrightnow

Copy link
Copy Markdown
Contributor Author

Good catch — thanks. You're right: the clean-EOF path failed the agentic.execute span but still called stage.finish(None), so the inference stage recorded success for the same incomplete upstream response.

Fixed in bca87963 (pushed to this PR branch):

  • messages_stream.rs: the round-end stage.finish now takes FailureCategory::Stream when has_completed_round() is false, so clean EOF fails both the execution span and the inference stage. Normal completed rounds still finish with no error, and the earlier error paths (which already finish with their own category and return) are unchanged.
  • execution_metrics_test.rs: added messages_stream_clean_eof_fails_both_execution_and_inference_stage, which asserts execution outcome=failed and agentic.stage.duration{stage=inference,error.type=stream}=1 together for the same clean-EOF response.

Verification: full metrics suite (17 passed), the original span regression, fmt, clippy (-D warnings), pre-commit (incl. the 500-line file-size check) all pass; full workspace suite has only the two pre-existing environment-specific 502-vs-504 cases.

The clean-EOF path failed the execution span but still finished the inference
stage with no error, marking it successful for the same incomplete upstream
response. Finish the stage with FailureCategory::Stream when the round did not
complete, and assert the stage outcome alongside the execution outcome in a
metrics regression test.

Signed-off-by: Jack Wei <[email protected]>
@justrightnow
justrightnow force-pushed the fix/313-premature-eof-span branch from bca8796 to 13909e3 Compare November 21, 2026 15:03

@franciscojavierarceo franciscojavierarceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the clean-EOF path now marks both the inference stage and execution outcome as failed, with a focused regression test. looks good to me.

@franciscojavierarceo
franciscojavierarceo merged commit 91c13ae into vllm-project:main Nov 22, 2026
15 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.

2 participants