Skip to content

SDK hardening - onError, Callbacks & audio pipeline control - #123

Merged
louisjoecodes merged 32 commits into
mainfrom
feat/sdk-hardening
Nov 4, 2025
Merged

SDK hardening - onError, Callbacks & audio pipeline control#123
louisjoecodes merged 32 commits into
mainfrom
feat/sdk-hardening

Conversation

@louisjoecodes

@louisjoecodes louisjoecodes commented Nov 3, 2025

Copy link
Copy Markdown
Collaborator
  • Hardened conversation startup: new metrics, structured error callbacks, and normalized handling of streaming vs final agent responses.
  • Expanded API surface for parity with Android - callbacks for agent/user transcripts, VAD scores, tool responses, feedback gating, conversation metadata, and alignment events.
  • Introduced AudioPipelineConfiguration so clients can tune mute mode, AGC, recording warm-up, speech-activity hooks, and voice-processing bypass directly through the SDK.

@louisjoecodes
louisjoecodes requested a review from Copilot November 3, 2025 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive startup state tracking, audio alignment support, and improved testing infrastructure to the ElevenLabs SDK. The changes enable better observability of the conversation initialization process and expose character-level timing information from audio synthesis.

  • Added startup state machine tracking with metrics for each initialization phase (token fetch, room connection, agent ready, conversation init)
  • Implemented audio alignment support with character-level timing information for TTS output
  • Introduced protocol-based dependency injection to enable comprehensive unit testing with mocks

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Sources/ElevenLabs/Conversation.swift Refactored startup flow to track state transitions and metrics; added audio alignment and callback support; introduced dependency injection pattern
Sources/ElevenLabs/Networking/ConnectionManager.swift Added agent ready wait mechanism with timeout support; exposed publish method; implemented error handler callback
Sources/ElevenLabs/Protocol/IncomingEvents.swift Added AudioAlignment struct to support character-level timing metadata for audio events
Sources/ElevenLabs/Protocol/EventParser.swift Updated audio event parser to handle optional alignment data
Sources/ElevenLabs/Models/ConversationConfig.swift Added multiple event callbacks and configuration options for startup behavior, audio pipeline, and event notifications
Sources/ElevenLabs/Models/AudioPipelineConfiguration.swift New configuration struct for controlling microphone behavior and voice activity detection
Sources/ElevenLabs/DI/Dependencies.swift Introduced protocols for dependency injection (TokenServicing, ConnectionManaging, ConversationDependencyProvider)
Tests/ElevenLabsTests/Mocks/*.swift Created comprehensive mock implementations and test dependency provider for unit testing
Tests/ElevenLabsTests/Tests/ConversationTests.swift Added extensive test coverage for startup flows, error handling, and callback behavior
Tests/ElevenLabsTests/Tests/EventParserTests.swift Added test for parsing audio events with alignment data
Sources/ElevenLabs/Protocol/schemas/agent.asyncapi.yaml Added AudioAlignment schema definition matching the server API specification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/ElevenLabs/Models/ConversationConfig.swift
Comment thread Sources/ElevenLabs/Conversation.swift Outdated
Comment thread Tests/ElevenLabsTests/Mocks/MockTokenService.swift Outdated
Comment thread Sources/ElevenLabs/Conversation.swift Outdated
Comment thread Sources/ElevenLabs/Conversation.swift
…tion options

Added documentation for SDK hardening features:
- Error handling with onError callback
- Startup state monitoring with onStartupStateChange
- Event callbacks (onAgentResponse, onUserTranscript, onInterruption, etc.)
- Audio alignment for word highlighting
- Audio pipeline configuration
- Network configuration (ICE/TURN strategies)
- Startup configuration (timeouts, retries)
- VAD score monitoring
- Complete configuration examples

Documents all features added in the SDK hardening effort.
…requirement)

SwiftFormat's default 'redundantSelf' rule removes self., but Swift 6 strict
concurrency REQUIRES explicit self. in closures to make capture semantics clear.

This config ensures swiftformat won't break strict concurrency compliance.
@louisjoecodes louisjoecodes changed the title feat/sdk hardening SDK hardening - onError, Callbacks & audio pipeline control Nov 4, 2025
@louisjoecodes
louisjoecodes merged commit a2cf46a into main Nov 4, 2025
2 of 3 checks passed
@louisjoecodes
louisjoecodes deleted the feat/sdk-hardening branch November 4, 2025 19:53
renal128 added a commit that referenced this pull request May 17, 2026
The errorHandler hook on ConversationDependencyProvider and
ConnectionManaging was a no-op in prod since #123 — Dependencies always
returned nil, and 5 of 6 connection-manager call sites already throw the
same error. Removed from the provider, both real connection managers,
both mocks, and TestDependencyProvider.
renal128 added a commit that referenced this pull request May 18, 2026
The errorHandler hook on ConversationDependencyProvider and
ConnectionManaging was a no-op in prod since #123 — Dependencies always
returned nil, and 5 of 6 connection-manager call sites already throw the
same error. Removed from the provider, both real connection managers,
both mocks, and TestDependencyProvider.
renal128 added a commit that referenced this pull request May 19, 2026
The errorHandler hook on ConversationDependencyProvider and
ConnectionManaging was a no-op in prod since #123 — Dependencies always
returned nil, and 5 of 6 connection-manager call sites already throw the
same error. Removed from the provider, both real connection managers,
both mocks, and TestDependencyProvider.
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.

2 participants