Skip to content

feat(audio): add shared session recording infrastructure - #1067

Open
David Elner (delner) wants to merge 12 commits into
mainfrom
feat/audio-recording-core
Open

David Elner (delner) wants to merge 12 commits into
mainfrom
feat/audio-recording-core

Conversation

@delner

Copy link
Copy Markdown
Contributor

Adds a common recording layer that turns caller and agent audio into an aligned
session recording, exported progressively as attachments. This is the foundation
for the LiveKit integration and future Pipecat recording work.

An adapter supplies audio, its position in the conversation, and a capture policy:

from braintrust._audio.session import AudioSessionRecorder

recording = AudioSessionRecorder(
    session_span,
    sources=("caller", "agent"),
    allowed=can_record_audio,
)
recording.record(
    "caller", pcm,
    sample_rate_hz=24_000, channels=1, offset_ns=0,
)
await recording.finish()

The session accumulates timed recording segments with aligned audio channels:

session.input.audio
├─ part-0   00:00–01:00   caller | agent
└─ part-1   01:00–02:00   caller | agent

Design

flowchart LR
    P[Positioned PCM] --> R[Shared timeline / recorder]
    R --> W[Background normalization / encoding]
    W --> U[Attachment upload]
    U --> S[Session references + segment metadata]
Loading
  • The AudioSessionRecorder maintains a timeline that is used to preserve silence, channel alignment and source identity across audio streams with different sample rates.
  • PCM audio segments are progressively flushed as duration and byte thresholds are reached.
  • Middleware applies encoding to the flushed PCM audio.
  • When the session is finished, the remaining audio is drained.

Add positioned PCM recording, middleware, progressive v3 export, bounded native workers and direct attachment uploads. Include PCM/WAV support, cancellation and upload lifecycle coverage, and audio-only attachment request timeouts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T19:11:33.933706Z a8fab87 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c033ff19a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/_audio/recorder.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a67658b923

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/_audio/recorder.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14aa263c5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/src/braintrust/_audio/recorder.py Resolved

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants