Skip to content

feat(hearing): carry the finals' times on the LiveKit transcription streams - #198

Merged
jddunn merged 4 commits into
masterfrom
feat/livekit-transcription-times
Oct 9, 2026
Merged

jddunn merged 4 commits into
masterfrom
feat/livekit-transcription-times

Conversation

@jddunn

@jddunn jddunn commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds agentos.start_ms and agentos.end_ms to a final's transcription stream, read by transcriptEventFromLiveKit.

LiveKitTranscriptionOutput writes them beside lk.segment_id, lk.transcription_final and lk.transcribed_track_id when the transcript carries startMs and endMs: the times on the session's audio clock, rounded to whole milliseconds and written in decimal digits (a time that is negative or not a safe integer once rounded is left out). An interim carries neither, a final without times carries neither, and a replayed final carries the two it was first written with. transcriptEventFromLiveKit() reads them into the event's startMs and endMs, so the lines of a page's TranscriptLedger hold the times; a value that is not whole milliseconds in decimal digits is ignored. The names are exported as TRANSCRIPTION_TIME_ATTRIBUTES from @framers/agentos/io/voice-pipeline and its browser entry, beside TRANSCRIPTION_FAILED_ATTRIBUTE. The voice pipeline guide's LiveKit section (docs/features/VOICE_PIPELINE.md) describes both.

Linked issues

Closes #197

Type of change

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

Tests first, on CI: four cases in LiveKitTranscriptionOutput.test.ts over a fake room (the two times beside the three lk. attributes; neither on an interim nor on a final without times; the same two on a replay, read back into a page's ledger; whole milliseconds) and three in transcriptLedger.test.ts (the times read as numbers; a value that is not whole milliseconds in decimal digits ignored while the other time is read; a page's ledger line holding the times its final carried). A fifth case in LiveKitTranscriptionOutput.test.ts, added after the change, writes a start of zero as '0' and reads it back into a page's line as 0, so a check that takes zero for no time fails it.

Six of those seven cases failed on the test-first commit (CI run 37957337228), every other test file passing: in LiveKitTranscriptionOutput.test.ts the two times beside the lk. attributes, the same two on a replay and whole milliseconds, and in transcriptLedger.test.ts all three. The seventh, neither time on an interim nor on a final without times, passed there because the writer wrote no times yet; it fails a writer that puts the times on an interim. The type check passed on that commit because the tests use the attribute strings ('agentos.start_ms', 'agentos.end_ms') directly, not the constant the change adds. All eight cases pass with the change. CI on the head: Test & Lint (lint, type check, the browser entry's import walk, the suite with coverage), Batch-1 gated tests and Release dry run (a patch release) are green.

Migration notes

None: two new attributes on a final's stream, which a reader that does not know them ignores, and one new export.

Checklist

  • Tests cover the changed behavior.
  • Docs are updated.
  • The title follows Conventional Commits, with ! before the colon for a change that breaks users (feat!: or feat(api)!:).
  • No secrets or private data are included.
  • Every automated review thread is settled (how).
  • I have read this change and can explain every line.

Summary by Sourcery

Carry valid final transcription timing through LiveKit streams into transcript ledger entries.

New Features:

  • Preserve final transcription start and end times in LiveKit streams and restore them when reading transcript events.

Enhancements:

  • Add a shared export for transcription time attributes and validate timestamp values as non-negative whole milliseconds.

Documentation:

  • Document transcription timestamp attributes and their handling in the LiveKit voice pipeline guide.

Tests:

  • Add coverage for timestamp emission, replay, rounding, validation, and ledger persistence.

Summary by CodeRabbit

  • New Features
    • Final transcript segments now preserve start and end times as whole-millisecond values, including when transcripts are replayed. Invalid or unavailable times are omitted.
    • Valid timing attributes are available on parsed transcript events; malformed values are ignored.
  • Documentation
    • Updated transcription documentation to describe timing attributes on final segments and their absence on interim segments.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: d7c89c9b-e679-4732-8d80-2a2c84e4969a

📥 Commits

Reviewing files that changed from the base of the PR and between 002b4ee and 9dc9f9e.


📒 Files selected for processing (7)
  • docs/features/VOICE_PIPELINE.md
  • src/io/hearing/LiveKitTranscriptionOutput.ts
  • src/io/hearing/__tests__/LiveKitTranscriptionOutput.test.ts
  • src/io/voice-pipeline/__tests__/transcriptLedger.test.ts
  • src/io/voice-pipeline/browser.ts
  • src/io/voice-pipeline/index.ts
  • src/io/voice-pipeline/transcriptLedger.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

Final LiveKit transcript messages now carry optional start and end timestamps as decimal-millisecond attributes. The transcript reader parses valid attributes into event fields, and the ledger preserves them. Interims omit timing attributes. The attribute names are exported from the voice-pipeline entry points.

Changes

LiveKit transcript timing

Layer / File(s) Summary
Define and parse transcript timestamps
src/io/voice-pipeline/transcriptLedger.ts, src/io/voice-pipeline/index.ts, src/io/voice-pipeline/browser.ts, src/io/voice-pipeline/__tests__/transcriptLedger.test.ts, docs/features/VOICE_PIPELINE.md
The ledger defines and exports the timestamp attribute names. It parses valid decimal safe-integer values into final transcript events. Tests cover absent and invalid values, and the documentation describes the reader behavior.
Write and replay final timestamps
src/io/hearing/LiveKitTranscriptionOutput.ts, src/io/hearing/__tests__/LiveKitTranscriptionOutput.test.ts, docs/features/VOICE_PIPELINE.md
Final sends include rounded, nonnegative safe-integer timestamps when available. Replay retains stored times, while interims omit timing attributes. Tests cover rounding, omission, replay, and zero timestamps.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LiveKitTranscriptionOutput
  participant LiveKit
  participant transcriptEventFromLiveKit
  participant TranscriptLedger
  LiveKitTranscriptionOutput->>LiveKit: Send final with timestamp attributes
  LiveKit->>transcriptEventFromLiveKit: Provide final event and attributes
  transcriptEventFromLiveKit->>TranscriptLedger: Record parsed event times
Loading

Merge Risk: ⚪ Minimal · up to 9dc9f

This change adds optional timing attributes to final LiveKit transcripts and reads them back. Existing behavior for interims and untimed finals is unchanged. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check Passed Issue #197 requires final LiveKit streams to carry agentos.start_ms and agentos.end_ms, and requires transcriptEventFromLiveKit() to restore them. LiveKitTranscriptionOutput.write() stores eve…
Out of Scope Changes check Passed The changes stay within issue #197. The implementation, shared attribute export, browser export, tests, and LiveKit documentation directly support carrying final transcription times through LiveKit an…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files. (1 skipped: 1 …
Title check Passed The title clearly and concisely describes the main change: carrying final transcription times through LiveKit transcription streams. It follows Conventional Commits format.
Description check Passed The description is complete and matches the repository template. It explains the change, links issue #197, identifies the feature type, documents verification and CI results, states migration impact, …


✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds end-to-end support for carrying final transcript start and end times through LiveKit attributes, replay, event parsing, and TranscriptLedger storage, with validation that only safe whole-millisecond decimal values are serialized or read.

File-Level Changes

Change Details Files
Persist final transcription timing metadata in LiveKit stream attributes and restore it when consuming transcripts.
  • Serialize valid start and end times as decimal whole-millisecond attributes only for final transcripts.
  • Preserve timing attributes during final replay, while omitting them from interims and untimed finals.
  • Parse valid timing attributes into transcript events and ignore malformed values independently.
  • Propagate parsed times into TranscriptLedger final lines.
src/io/hearing/__tests__/LiveKitTranscriptionOutput.test.ts
src/io/voice-pipeline/__tests__/transcriptLedger.test.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#197 Have LiveKitTranscriptionOutput write agentos.start_ms and agentos.end_ms attributes on final transcription streams when valid startMs and endMs values are present, while omitting them from interim transcripts and finals without valid times, including preserving them for replayed finals. ❌ The provided diff only adds tests; it does not show changes to LiveKitTranscriptionOutput or its replay/storage logic that write and preserve these attributes.
#197 Have transcriptEventFromLiveKit parse valid agentos.start_ms and agentos.end_ms attributes into numeric startMs and endMs event fields, ignoring invalid values so TranscriptLedger entries retain the final's times. ❌ The provided diff only adds tests and does not show production changes to transcriptEventFromLiveKit or related exports/parsing logic that read these attributes.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

jddunn added 2 commits October 9, 2026 09:45
…treams

LiveKitTranscriptionOutput writes agentos.start_ms and agentos.end_ms on a
final whose transcript has startMs and endMs, rounded to whole milliseconds,
and a replay sends the times the final was first written with.
transcriptEventFromLiveKit reads them back as numbers and ignores a value
that is not whole milliseconds in decimal digits. The names are exported as
TRANSCRIPTION_TIME_ATTRIBUTES from the voice pipeline's entries.
@jddunn
jddunn force-pushed the feat/livekit-transcription-times branch from 6edfb77 to 6238164 Compare October 9, 2026 16:45
jddunn added 2 commits October 9, 2026 10:06
…_ATTRIBUTES

The guide named the constant in the paragraph on
@framers/agentos/io/hearing/livekit, which does not export it. It comes
from @framers/agentos/io/voice-pipeline and its browser entry, beside
TRANSCRIPTION_FAILED_ATTRIBUTE.
A final whose startMs is 0 is written with agentos.start_ms '0' and read
back into a page's ledger line as 0. The writer, the reader and the
ledger compare each time with undefined; this case keeps a truthiness
check on any of them from dropping a line's start without a test failing.
@jddunn
jddunn marked this pull request as ready for review October 9, 2026 17:13
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 9, 2026 17:13
@sourcery-ai

sourcery-ai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 12 hours and 26 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Preserve final transcription times across LiveKit streams

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Carry final transcription times through LiveKit streams into page transcript ledgers.
Diagram

graph TD
  STT["STT Session"] --> Writer["LiveKit Output"] --> Saved["Final Ledger"] --> Streams["LiveKit Streams"] --> Reader["Event Parser"] --> Page["Page Ledger"]
  Writer -->|interims| Streams
Loading
High-Level Assessment

Using attributes on standard LiveKit transcription streams preserves compatibility with existing text handlers. Reusing the final ledger for replay avoids a separate timing cache; a custom stream payload would require different readers.

Files changed (7) +217 / -15

Enhancement (4) +82 / -13
LiveKitTranscriptionOutput.tsWrite valid final times to LiveKit streams +40/-6

Write valid final times to LiveKit streams

• Rounds and serializes available final times as non-negative, safe whole milliseconds. Interims omit the attributes, while replay uses times retained on the final ledger line.

src/io/hearing/LiveKitTranscriptionOutput.ts

browser.tsExport time attribute names from the browser entry +1/-0

Export time attribute names from the browser entry

• Re-exports the shared transcription time attribute constant for browser consumers.

src/io/voice-pipeline/browser.ts

index.tsExport time attribute names from the main entry +1/-0

Export time attribute names from the main entry

• Re-exports the shared transcription time attribute constant from the voice-pipeline package entry.

src/io/voice-pipeline/index.ts

transcriptLedger.tsDefine and parse transcription time attributes +40/-7

Define and parse transcription time attributes

• Adds shared names for the start and end attributes. The LiveKit event parser reads independently validated decimal whole-millisecond values into numeric event fields.

src/io/voice-pipeline/transcriptLedger.ts

Tests (2) +133 / -0
LiveKitTranscriptionOutput.test.tsTest timing emission, omission, replay, and zero +87/-0

Test timing emission, omission, replay, and zero

• Adds fake-room tests for final attributes, untimed finals and interims, replay into a page ledger, rounding and invalid values, and a start time of zero.

src/io/hearing/tests/LiveKitTranscriptionOutput.test.ts

transcriptLedger.test.tsTest timing parsing and ledger persistence +46/-0

Test timing parsing and ledger persistence

• Checks numeric time extraction, rejection of malformed or unsafe values without losing the other time, and storage on final ledger lines.

src/io/voice-pipeline/tests/transcriptLedger.test.ts

Documentation (1) +2 / -2
VOICE_PIPELINE.mdDocument final timing attributes and reader behavior +2/-2

Document final timing attributes and reader behavior

• Explains where the time-attribute constant is exported, when finals carry times, how replay preserves them, and how the reader handles invalid values.

docs/features/VOICE_PIPELINE.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Negative start times appear as zero 🐞 Bug ≡ Correctness
Description
wholeMs() rounds before checking for a negative time, so a value such as -0.1 becomes negative
zero and is serialized as '0'. When a final carries that value, transcriptEventFromLiveKit()
accepts it and the page ledger records a start of zero rather than omitting the invalid time.
Code

src/io/hearing/LiveKitTranscriptionOutput.ts[R181-182]

+  const whole = Math.round(ms);
+  return whole >= 0 && Number.isSafeInteger(whole) ? String(whole) : undefined;
Evidence
wholeMs() rounds the input before its nonnegative check; JavaScript rounds -0.1 to -0, which
passes that check and stringifies as '0'. timeAttributes() writes the result, while readMs()
accepts '0' and the reader assigns it to the event.

src/io/hearing/LiveKitTranscriptionOutput.ts[169-182]
src/io/voice-pipeline/transcriptLedger.ts[258-274]
src/io/voice-pipeline/transcriptLedger.ts[136-146]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`wholeMs()` accepts negative fractional times that round to negative zero, then writes them as `'0'`.
## Fix Focus Areas
- src/io/hearing/LiveKitTranscriptionOutput.ts[179-183]
- src/io/hearing/__tests__/LiveKitTranscriptionOutput.test.ts[157-166]
## Recommended Fix
Reject a negative input before rounding it, while preserving a genuine zero. Add a test with a negative fractional time that currently serializes as `'0'`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@jddunn

jddunn commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jddunn
jddunn merged commit 9a65feb into master Oct 9, 2026
11 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 9, 2026
## [0.13.12](v0.13.11...v0.13.12) (2026-10-09)

### feat

* **hearing:** carry the finals' times on the LiveKit transcription streams (#198) ([9a65feb](9a65feb))

### docs

* sixth round of audit follow-ups to the guides (#195) ([002b4ee](002b4ee))
@jddunn
jddunn deleted the feat/livekit-transcription-times branch October 10, 2026 18:58
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.

The finals' times on the LiveKit transcription streams

1 participant