fix(recorder): multi-turn runs must produce distinct fixtures (1.19.3)#166
Merged
AlemTuzlak merged 2 commits intomainfrom May 8, 2026
Merged
fix(recorder): multi-turn runs must produce distinct fixtures (1.19.3)#166AlemTuzlak merged 2 commits intomainfrom
AlemTuzlak merged 2 commits intomainfrom
Conversation
75658a1 to
dd03edf
Compare
commit: |
ranst91
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--recordmode now writesturnIndexandhasToolResultto the saved fixture'smatchblock, so multi-turn agent runs (tool-call → tool-result → follow-up) record as N distinct fixtures instead of collapsing into one and silently dropping the follow-up turn on replay.What was broken
A single agent run usually issues several LLM calls that share the same last user message:
messages: [user]→ tool call.messages: [user, assistant(tool_call), tool(result)]→ text reply.buildFixtureMatchwrote onlyuserMessage. Recording call 0 wrote a fixture withmatch: { userMessage: "..." }and pushed it into the in-memoryfixturesarray. The matcher then matched that fixture for call 1 (substring of the last user message is unchanged), the recorder was skipped, the canned tool-call response was replayed, and the follow-up turn was silently lost. Replays of the resulting single fixture looped on the tool call until the framework's recursion limit fired.CopilotKit's beautiful-chat showcase compose worked around this by hot-patching
dist/recorder.jsat container start — fragile and dropped on every container restart.What changed
src/recorder.ts—buildFixtureMatchwritesturnIndex(count ofassistantmessages) andhasToolResult(any priorrole:"tool"present) for chat-shaped requests. Embedding short-circuit and multimedia endpoints (no messages) are guarded out. Composes cleanly with themodelfield added in 1.18.0 for fal.ai.src/recorder.ts—isEmptyMatchnarrowed to check onlyuserMessage/inputText/endpointso the empty-match-warning behavior is preserved (the new disambiguators don't constitute a meaningful match key on their own).src/__tests__/recorder.test.ts— newrecorder multi-turn disambiguationdescribe block with 4 tests:CHANGELOG.md+package.json— 1.19.3 release notes and version bump.Compatibility
turnIndexandhasToolResultwere already accepted by the validator and matcher (1.16.0). Existing fixtures that lack these fields continue to match exactly as before.messages.length > 0, and themodelfield added in 1.18.0 for fal.ai composes orthogonally with the new fields.Test plan
pnpm test src/__tests__/recorder.test.ts— 85/85 pass (4 new + 81 existing)pnpm test src/__tests__/turn-index.test.ts— 12/12 pass (matcher coverage unchanged)pnpm test— 2832/2835 pass; the 3 failures are pre-existing Windows-specific infrastructure tests (symlink invocation, SIGTERM, XDG_CACHE_HOME path separators), all unrelated to this change.pnpm run lint— clean.pnpm exec prettier --check src/recorder.ts src/__tests__/recorder.test.ts CHANGELOG.md package.json— clean.pnpm run build— clean (tsdown, 245 files, no type errors).