You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c773a37
Browse filesBrowse the repository at this point in the historyBrowse files
feat: apply streamingProfile timing to non-streaming responses (#545)
## What
`ttft`/`tps`/`jitter` (and `recordedTimings`) only ever applied on the
SSE path — a non-streaming request (`stream: false`) wrote its JSON body
back immediately, ignoring whatever `streamingProfile` the fixture
declared. Adds `calculateTotalDelay`, which sums `calculateDelay` over
the same chunk count a streamed response at the same `chunkSize` would
use, so a fixture's timing is identical whether it's served streamed or
not. Wired into all three non-streaming completion branches (text, tool
calls, and the refusal/content_filter/reasoning misbehavior terminal) in
the OpenAI chat-completions handler.
## Why
Matters for load/perf-testing agent setups where a lot of real traffic
is non-streaming on purpose (sub-agent calls, tool-chain orchestration,
guardrail/classifier calls) — those got zero simulated latency before
this, which throws off any test trying to reproduce realistic timing
across a call tree.
## Gates
- `pnpm format:check`, `pnpm lint`, `pnpm typecheck`, `pnpm build`: pass
- `pnpm test`: full suite green (0 failures)
- Directly relevant files: `streaming-physics.test.ts` (28 tests,
including new `calculateTotalDelay` unit tests) + `server.test.ts` (85
tests, including a new non-streaming timing regression test): pass
## Tests
- `src/__tests__/streaming-physics.test.ts`: unit tests for
`calculateTotalDelay` — fallback-latency-once semantics, ttft +
per-chunk tps, sub-chunk and zero-length content, parity with summing
`calculateDelay` over the same range, `recordedTimings` support,
`replaySpeed` scaling, non-negativity under jitter.
- `src/__tests__/server.test.ts`: a non-streaming request against a
fixture with `streamingProfile: { ttft: 60, tps: 1000 }` now takes at
least the ttft floor, where it previously returned in a few ms.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@
33
33
34
34
- MCP `resources/read`: a resource whose content has neither `text` nor `blob` (including one added without content) now reads as `"text": ""` (#533)
35
35
- MCP `resources/read`: the read uses the resource definition's `mimeType` when its content has none (#533)
36
+
- OpenAI chat completions only, non-streaming (`stream: false`): opt-in timing. A fixture with an explicit `streamingProfile` (`ttft`/`tps`/`jitter`) or `recordedTimings` now delays the JSON response by about the total its streamed content chunks would take. Before, only the SSE path used these values. Fixtures without them are not delayed: bare `latency` and the global `--latency` stay inter-SSE-chunk gaps and do not slow down non-streaming responses. Other providers are unchanged (#545)
0 commit comments