Skip to content

fix: sweep — 15 fixes across router, realtime, recorder, fal-audio, gemini-interactions, and drift infra#230

Merged
jpr5 merged 9 commits into
mainfrom
fix/pre-existing-sweep
May 21, 2026
Merged

fix: sweep — 15 fixes across router, realtime, recorder, fal-audio, gemini-interactions, and drift infra#230
jpr5 merged 9 commits into
mainfrom
fix/pre-existing-sweep

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented May 19, 2026

Summary

Fixes 15 pre-existing issues identified during CR of PRs #226 and #229, plus 3 additional improvements from post-CR review. Grouped by area:

Router + Recorder — systemMessage array exact-match logic bug (unsatisfiable for 2+ needles), missing elevenlabs-tts/translation in endpoint compatibility filter, Content-Type empty-string fallback (?? → ||), EndpointType derived from FixtureMatch, negative guards on Gemini Interactions outputs detection, turnIndex/hasToolResult scoped to chat endpoints

WS-Realtime — incomplete session.update rollback (now captures full snapshot), missing Beta flat fields for noise reduction, transcription, and turn_detection, join all text content parts in realtimeItemsToMessages, ws.send try-catch with debug logging for close races

WS-Gemini-Live — deterministic tool call IDs replaced with random generateToolCallId() to prevent cross-turn collisions, pre-computed resolvedToolCalls for wire/history ID consistency, unrecognized-role warning, ws.send try-catch with debug logging, two new tests covering the random-ID fallback path

Gemini Interactions — interactionsUsage honors Gemini-native field names (promptTokenCount/candidatesTokenCount/totalTokenCount), truncateAfterChunks only counts content.delta events, webSearches warning on tool-call-only branch, documented _endpointType = "chat" rationale

fal-audio + ElevenLabs — all journal entries now use flattenHeaders(req.headers) instead of {}, handleSyncRun accepts RawJSONResponse fixtures

Helpers, types, transcription — resolveUsage extended with Gemini-native token fields, error cause preserved in factory rethrow, buildEmbeddingResponse accepts optional usage, extractFormField escapes regex metacharacters, types.ts header LLMock → aimock

Drift test infra — retry logging with body consumption, broadened redactUrl to cover api_key/apikey/token/access_token patterns, URL threaded into assertOk/parseJsonResponse for redacted error context, parseDataOnlySSE [DONE] filter fix, parseTypedSSE multi-line data handling with null guards and error context

Test plan

  • 3170 tests pass (90 files)
  • TypeScript clean
  • Prettier clean
  • ESLint clean

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@230

commit: c74a0f7

@jpr5 jpr5 force-pushed the fix/pre-existing-sweep branch 4 times, most recently from cad6cae to f770b80 Compare May 19, 2026 13:35
@jpr5 jpr5 changed the title fix: pre-existing sweep — 15 fixes across router, realtime, recorder, fal-audio, gemini-interactions, and drift infra fix: sweep — 15 fixes across router, realtime, recorder, fal-audio, gemini-interactions, and drift infra May 21, 2026
@jpr5 jpr5 force-pushed the fix/pre-existing-sweep branch from f770b80 to c74a0f7 Compare May 21, 2026 18:47
jpr5 added 9 commits May 21, 2026 12:51
…ack, fixture detection guards

Collapse dead exact-match branch in array systemMessage matching (both
paths were identical). Add elevenlabs-tts and translation to endpoint
compatibility filter. Change Content-Type ?? to || for empty-string
fallback. Derive EndpointType from FixtureMatch (single source of
truth). Add negative guards to Gemini Interactions outputs detection.
Scope turnIndex/hasToolResult to chat endpoints only.
….send safety

Complete session.update rollback with full snapshot instead of just
model/type. Add missing Beta flat fields for noise reduction,
transcription, and turn_detection. Join all text content parts in
realtimeItemsToMessages. Wrap sendEvent in try-catch with debug
logging for TOCTOU safety on WebSocket close races.
…age in Gemini Live

Replace deterministic call_gemini_${name}_${i} IDs with random
generateToolCallId() to prevent cross-turn collisions. Pre-compute
resolvedToolCalls so wire messages and conversation history share the
same IDs. Wrap ws.send in try-catch with debug logging for close race
safety. Add unrecognized-role warning to geminiTurnsToMessages. Add
two tests covering the random-ID fallback path for both toolResponse
and clientContent functionResponse without explicit id fields.
…ches warning

Honor Gemini-native field names (promptTokenCount, candidatesTokenCount,
totalTokenCount) in interactionsUsage fallback chain. Only count
content.delta events for truncateAfterChunks — framing events should
not consume chunk budget. Add webSearches warning to tool-call-only
branch. Document why _endpointType stays "chat" for compatibility.
…venLabs

Use flattenHeaders(req.headers) in all journal entries instead of
empty {}. Add isJSONResponse branch to handleSyncRun for queue-walk
recordings that stored the final fal envelope as RawJSONResponse.
…aimock header

Extend resolveUsage to accept Gemini-native token field names
(promptTokenCount, candidatesTokenCount, totalTokenCount). Preserve
error cause in resolveResponse factory rethrow. Accept optional usage
in buildEmbeddingResponse. Escape regex metacharacters in
extractFormField. Update types.ts header from LLMock to aimock.
…dening

Add retry logging and body consumption in fetchWithRetry. Broaden
redactUrl to cover api_key, apikey, token, access_token patterns.
Thread URL into assertOk/parseJsonResponse for redacted error context.
Fix parseDataOnlySSE [DONE] filter to avoid false positives on content
containing [DONE]. Rewrite parseTypedSSE to handle multi-line data
frames with proper null guards and error context.
…traces as infra errors

Invoke vitest directly via npx instead of pnpm test:drift to avoid the
pnpm prefix line that broke JSON parsing. Add stack trace patterns
(Error:, file: frames, STACK_TRACE_ERROR) to infraIndicators so raw
vitest failures from API/network issues are classified as infrastructure
errors instead of crashing the collector.
@jpr5 jpr5 force-pushed the fix/pre-existing-sweep branch from 6665ee4 to 28c4f22 Compare May 21, 2026 19:52
@jpr5 jpr5 merged commit 9e3bfae into main May 21, 2026
21 of 22 checks passed
@jpr5 jpr5 deleted the fix/pre-existing-sweep branch May 21, 2026 19:52
jpr5 added a commit that referenced this pull request May 21, 2026
## Summary

- Wrap all 15 exported provider functions in `withInfraErrorTag()` so
transient API failures (rate limits, network timeouts, auth errors)
throw with a structured `INFRA_ERROR: <provider> — <message>` prefix
instead of raw stack traces
- Add `/^INFRA_ERROR:/m` to the collector's `infraIndicators` array so
these are classified as infrastructure errors and don't crash the
pipeline

Follows up on PR #230 which fixed the collector's JSON parsing and added
basic stack trace classification. This change moves the tagging upstream
to the test layer so the collector never sees unparseable failures from
transient errors.

## Test plan

- [x] 3202 tests pass (90 files)
- [x] Prettier clean
- [x] ESLint clean
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.

1 participant