Skip to content

feat(voice): add eval-scoped WebSocket helpers - #1179

Draft
Alex Z (CLowbrow) wants to merge 6 commits into
mainfrom
codex/voice-eval-helpers
Draft

Alex Z (CLowbrow) wants to merge 6 commits into
mainfrom
codex/voice-eval-helpers

Conversation

@CLowbrow

@CLowbrow Alex Z (CLowbrow) commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds a framework-free WebSocket core for voice calls inside ordinary Eval / EvalAsync tasks. The application supplies an awaited agent connector and an existing simulated_user_id; dataset input and the eval tracing parent are carried automatically.

import os

from braintrust import Eval
from braintrust.voice import voice_task

Eval(
    "Voice evals",
    data=cases,
    task=voice_task(
        agent=connect_agent,
        simulated_user_id=os.environ["SIMULATED_USER_ID"],
    ),
    scores=scorers,
)

voice_task(...) starts a fresh call per row. Custom tasks use await run_voice_call(agent=..., simulated_user_id=..., input=input). Both require an active eval task. The project is inferred from its experiment or supplied as project_id. Saved-user instructions use the existing backend template renderer; only row input goes into its existing scenario wire field. Expected output and scorers stay in the eval.

The connector can call a local receiver or forward the serializable call context to an authenticated service:

async def connect_agent(call):
    return await agent_service.run_eval_call(call)

async def run_eval_call(call):
    async with voice.connect(call) as session:
        output = await run_agent(session)
    return session.result(agent_output=output)

The receiver's application audio bridge attaches session.set_audio_sink(..., clear=..., ended=...), sends agent PCM with session.send_audio(...), and drops interrupted agent output with session.clear_output(). The core owns the ready handshake, audio conversion/pacing, consumed-playback acknowledgements, interruption epochs, stop/finalization, and recording collection. It activates the supplied parent before agent construction, isolates concurrent call contexts, and flushes completed agent spans.

Results contain the application's agent_output, caller-only transcript, recording references/timeline, reason, and session/span IDs. Callback results are validated once at the eval boundary. Agent, simulator, recording, cancellation, and disconnect failures propagate; credentials are excluded from SDK logs and malformed-result errors.

The API retains the backend's fixed ten-minute call limit. It has no simulated-user CRUD/name lookup, standalone logger setup, or framework dependencies. Pipecat is a separate dependent draft PR; LiveKit is deferred.

Backend dependency

Requires the existing session endpoint's parent and recording additions and data plane feature version 149. The SDK checks the version before reserving a session. Deploy that backend capability first.

Validation

  • Dedicated voice nox session: 14 tests passed with local HTTP/WebSocket servers.
  • Covers local/remote evals using simulated-user IDs, dataset-input isolation, eval scope, concurrent tracing, pacing/acknowledgements, interruptions, recording errors, disconnects, cancellation, capacity retries, and credential redaction.
  • Production modules: Pyright zero errors. Scoped pinned pre-commit checks passed.
  • Existing integration tests/sessions are unchanged in this core PR.

Usage and the audio callback contract are documented in py/src/braintrust/voice/README.md.

@CLowbrow Alex Z (CLowbrow) changed the title feat(voice): add managed Python voice eval helpers feat(voice): add eval-scoped WebSocket helpers Nov 25, 2026

This branch has not been deployed

No deployments
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