Skip to content

fix(inference): accept numeric STT error codes#1231

Merged
davidzhao merged 4 commits intolivekit:mainfrom
Maples7:fix/stt-error-code-1230
Apr 11, 2026
Merged

fix(inference): accept numeric STT error codes#1231
davidzhao merged 4 commits intolivekit:mainfrom
Maples7:fix/stt-error-code-1230

Conversation

@Maples7
Copy link
Copy Markdown
Contributor

@Maples7 Maples7 commented Apr 11, 2026

Description

Accept numeric STT error codes in inference server events.

Changes Made

  • widen sttErrorEventSchema.code from string-only to string | number
  • add a focused regression test covering a numeric STT error code such as 429
  • keep the change scoped to STT error event parsing only

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included
  • Video demo: A small video demo showing changes works as expected and did not break any existing functionality using Agent Playground (if applicable)

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Additional Notes

This fixes the schema mismatch reported in #1230.

The bug is that some STT error payloads use numeric codes such as 429. Today those frames fail sttServerEventSchema.safeParseAsync(...) and are dropped as parse failures instead of surfacing as STT errors.

This PR is intentionally minimal and does not change any retry logic or higher-level error handling.


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 11, 2026

🦋 Changeset detected

Latest commit: c90d7db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 11, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@Maples7
Copy link
Copy Markdown
Contributor Author

Maples7 commented Apr 11, 2026

Additional reproduction evidence from a downstream integration:

  1. The current upstream schema on main and @livekit/agents@1.2.6 is still string-only for sttErrorEventSchema.code.
  2. A minimal Zod reproduction rejects { type: 'error', message: 'quota exceeded', code: 429 } with Expected string, received number.
  3. In agents/src/inference/stt.ts, a failed sttServerEventSchema.safeParseAsync(...) only logs Failed to parse STT server event and then continues, so the STT error frame is dropped.
  4. This is separate from a local turn-detector startup failure I debugged in my app: that startup issue prevented the worker from booting at all, while this upstream schema bug affects observability once the worker is otherwise healthy.

That separation matters because both failure modes can look identical from the client side: “I spoke, but no transcript or useful STT error showed up.”

Copy link
Copy Markdown
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch. looking at the server side, it doesn't seem possible for code to be a string

Comment thread agents/src/inference/api_protos.ts Outdated
davidzhao and others added 2 commits April 11, 2026 10:19
@davidzhao davidzhao merged commit ba1ea76 into livekit:main Apr 11, 2026
6 checks passed
@Maples7 Maples7 deleted the fix/stt-error-code-1230 branch April 15, 2026 08:57
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.

3 participants