Recorder replays a failed model stream as a successful partial stream

Open
#195 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@jihtsan is already working on this.

Since Oct 31, 2026.

  • #196 by @jihtsan — open

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
node.js, typescript
Domain
testing-qa

Research direction

Start by reading modelCall and the recording/model-answer data used by the @statelyai/agent/testing entry point, then trace how compareRecordings classifies model errors. The issue calls for regression coverage across AI SDK ReadableStreams and both OpenAI client methods, including cancellation and request-stage rejection. Done means JSON-round-tripped recordings replay iteration failures at the original phase and comparisons distinguish them from EOF and request-stage failures; an open linked pull request is already working on this issue.

Written by the indexing model from the issue text.

Description

Problem

On next (4c19918ea42e47d0e180a511961dd55c43aa614f), recorder model streams lose errors raised during iteration. A live stream that yields a partial chunk and then fails replays the same partial chunk followed by successful EOF. Error handling and retry paths can consequently differ during the very record/replay checks meant to validate equivalence.

modelCall catches failures while awaiting the provider call, but not failures while reading the returned ReadableStream or AsyncIterable. No iteration error reaches the JSON recording. This is separate from promise-like tool result classification (#193).

Reproduction

Used the complete built @statelyai/agent/testing CommonJS entry on Node24.22.1, with deterministic sources and no provider SDK request, keys or model service. An AI SDK-shaped model returns a ReadableStream whose first pull yields {type:"text-delta",id:"text0",delta:"partial"} and whose next pull errors with Error("connection reset"). Equivalent OpenAI-shaped clients expose chat.completions.create and responses.create returning async generators that yield that chunk, then throw the same error.

For each of the three wrapper paths:

  1. Wrap with recorder.model(model) or recorder.openai(client) and consume the stream: one partial chunk, then connection reset.
  2. JSON-round-trip recorder.recording.
  3. Wrap the same model/client with a new createRecorder({replay: recording}) and consume: one partial chunk, then normal EOF; no error.

The recorded model effect has stream:[partial], but no error describing the failed iteration.

Expected scope

Record iteration errors for both stream types and replay them at the original phase: resolve the call to a stream, yield all saved chunks, then throw when the next chunk is requested. Preserve existing error serialization and SDK error identity markers. Do not reuse the existing call-level error in a way that rejects before returning the stream or discards queued chunks.

Expose the optional iteration failure in the recording/model-answer data so it survives a JSON round trip and explicit translations; preserve compatibility with successful existing version1 recordings. compareRecordings should distinguish failed iteration from successful EOF and from a request-stage rejection, using the existing model-error divergence category.

Regression coverage should include partial-then-error, immediate iteration failure, ordinary/empty EOF, and request-stage rejection for the AI SDK ReadableStream and both OpenAI client methods. Check consumer cancellation/early return still reaches the source and is not recorded as a new provider failure. No retries, model calls or changes to tool semantics are needed.

Dominant language
TypeScript
Stars
508
Forks
29
Avg merge
8h 54m
Merged PRs (30d)
74

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statelyai/agent

All issues in statelyai/agent

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.