Skip to content

Improve actor abort/timeout handling, add TTS request IDs and VAD error events#1

Open
abdufelsayed wants to merge 1 commit intomainfrom
codex/explore-core-package-for-bugs
Open

Improve actor abort/timeout handling, add TTS request IDs and VAD error events#1
abdufelsayed wants to merge 1 commit intomainfrom
codex/explore-core-package-for-bugs

Conversation

@abdufelsayed
Copy link
Copy Markdown
Owner

Motivation

  • Prevent duplicate/late error emissions and race conditions when actors time out or are aborted by ensuring settled/aborted state is tracked.
  • Propagate VAD errors through the machine and metrics so VAD failures are reported like other providers.
  • Correlate TTS chunks/completion/errors to the originating request so stale audio from previous/filler TTS requests can be ignored.

Description

  • Add settled/timeout-safe error handling to llm and tts actors by introducing isSettled, timeoutId, and a finishWithError helper and by clearing timeouts on completion.
  • Include requestId on TTS actor input and on internal _tts:* events and wire the tts actor to attach requestId to chunk, complete, and error events.
  • Add activeTTSRequestId to the machine context and implement guards/actions (matchesActiveTTSRequest, speakingCurrentTTS, hasPendingSentencesForCurrentTTS) to ensure only the active TTS request affects state transitions and audio streaming.
  • Make vad and turn-detector actors and stt actor return early if abortSignal is already aborted to avoid starting providers after cancellation.
  • Add _vad:error event type and include VAD errors in the machine's recordError/emitAgentError flows and metrics.
  • Adjust audio streamer to use ArrayBuffer(0) for empty payloads and ensure TTS spawn flows generate nanoid() request ids for systemId and activeTTSRequestId tracking.
  • Update fake provider test helpers to support emitError on the VAD fake provider.

Testing

  • Ran the unit tests (Vitest) including updated files test/agent/error-recovery.test.ts and test/agent/interruption.test.ts, which exercise VAD error propagation, LLM/TTS timeout deduplication, and ignoring stale filler audio; all tests passed.
  • Verified new event typing for _tts:* and _vad:error via the test suite; no type regressions were reported.
  • Confirmed timeouts clear timers and do not produce additional agent:error events after a late provider error in the tests.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant