Skip to content

feat(endpoints): support explicit empty streaming chunks - #42

Merged
cquil11 merged 1 commit into
SemiAnalysisAI:release/agentx-v1.1from
ajcasagrande:ajc/allow-ttft-empty
Aug 20, 2026
Merged

feat(endpoints): support explicit empty streaming chunks#42
cquil11 merged 1 commit into
SemiAnalysisAI:release/agentx-v1.1from
ajcasagrande:ajc/allow-ttft-empty

Conversation

@ajcasagrande

@ajcasagrande ajcasagrande commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Adds --allow-empty-content for streaming OpenAI Chat Completions. Some compatible servers send explicit empty content or reasoning deltas before generated text. With this opt-in flag, AIPerf retains those events on the shared response timeline so TTFT reflects the first server stream event.

The default remains false, preserving existing behavior for all current benchmarks. The parser accepts only explicit empty strings from valid streaming Chat Completions chunks; usage-only, finish-only, null, and malformed events remain excluded.

Usage

CLI:

aiperf profile \
  --streaming \
  --allow-empty-content \
  --url http://localhost:8000 \
  --model <model> ...

YAML:

endpoint:
  streaming: true
  allow_empty_content: true

Metric semantics

  • TTFT uses the first retained stream event, including an opted-in empty delta.
  • TTFO still waits for the first non-empty user-visible output token.
  • Empty strings add zero output tokens.
  • Request latency, decode duration, TTST, and inter-chunk metrics share the same retained-response timeline.
  • Non-streaming Chat Completions behavior is unchanged.

Validation

  • pre-commit run --files ...
  • Focused unit suite: 69 passed
  • Real CLI reproduction confirms an empty leading chunk affects TTFT while TTFO remains near the configured first-token delay.

The in-repo mock server gained --emit-empty-chat-content solely to make this end-to-end timing case reproducible.

Known test-suite state

uv run pytest tests/unit/ -n auto currently reports four failures in health-server fixed-port tests, console ANSI styling, and a records-manager scenario fixture. The focused feature suite is green; these failures were not modified in this change.

@github-actions

github-actions Bot commented Aug 15, 2026

Copy link
Copy Markdown

Try out this PR

Quick install:

pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@e8ece5d29bd0285af1ced36fbc4c670328b2d58c

Recommended with virtual environment (using uv):

uv venv --python 3.12 && source .venv/bin/activate
uv pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@e8ece5d29bd0285af1ced36fbc4c670328b2d58c

Last updated for commit: e8ece5dBrowse code

Add an opt-in allow_empty_content endpoint setting for streaming OpenAI Chat Completions. Some compatible servers send an explicit empty content or reasoning delta before generated text; retaining that event gives TTFT and the shared response timeline the server-observed boundary without treating it as output text or tokens.

The default remains disabled. The parser accepts only typed Chat Completions chunks, preserves zero-token semantics, keeps TTFO tied to non-empty output, and ignores malformed stream events instead of raising. Focused metric and parser coverage verifies the enabled, disabled, empty-only, reasoning, and usage-only cases.

The in-repo mock server now supports --emit-empty-chat-content, which emits one leading empty content delta without token accounting.

Usage:

  aiperf-mock-server --emit-empty-chat-content --ttft 100
  aiperf profile --streaming --allow-empty-content --url http://127.0.0.1:8000 --model <model> ...

This makes the end-to-end timing distinction reproducible: TTFT observes the empty chunk while TTFO waits for the first non-empty output token.

Signed-off-by: Anthony Casagrande <acasagrande@nvidia.com>
@cquil11
cquil11 changed the base branch from master to release/agentx-v1.1 August 20, 2026 20:06
@cquil11
cquil11 marked this pull request as ready for review August 20, 2026 20:12
@cquil11
cquil11 merged commit efc0f66 into SemiAnalysisAI:release/agentx-v1.1 Aug 20, 2026
1 of 4 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