Recorder replays a failed model stream as a successful partial stream
Maintainers usually reply within 1 day
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:
- Wrap with
recorder.model(model)orrecorder.openai(client)and consume the stream: one partial chunk, thenconnection reset. - JSON-round-trip
recorder.recording. - 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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from statelyai/agent
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Trace JSON serialization loses own data keys and cross-realm Error detailsPossibly taken @jihtsan claimed this 33 days ago. Open
Difficulty 3/5 Half a day Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Recorder saves thenable and cross-realm Promise tool results as synchronous empty objectsPossibly taken @jihtsan claimed this 34 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
statelyai/agent#84 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
statelyai/agent#65 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zabuton-app/meguri#875 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
iruzen-dono/workless#117 ·
Maintainers usually reply within 1 day
-
area:api area:web wave wave:trivial
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vetro-protocol/vetro-monorepo#1321 ·
Maintainers usually reply within 1 day