Skip to content

feat(rime): add Prism settings and speech review callbacks - #8515

Open
naszzz wants to merge 13 commits into
livekit:mainfrom
naszzz:feat/prism-eight-issues
Open

naszzz wants to merge 13 commits into
livekit:mainfrom
naszzz:feat/prism-eight-issues

Conversation

@naszzz

@naszzz naszzz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add Prism speech speed, interruption settings, and speech review callbacks to the Rime realtime model. Apply stored settings only after server confirmation, and use cumulative transcripts to correct partial captions.

  • Add speed and review to RealtimeModel, plus mutable speed and interruption settings through update_options. Reject out-of-range speeds (0.85–1.3) immediately instead of failing the session at connect.
  • Keep minimum silence fixed at connection time. Omit new options by default.
  • Let the SDK own review callbacks and cancellation, including requests received before a LiveKit generation exists.
  • Preserve server timestamps in forwarded SDK events and use transcript deltas when cumulative text is absent.

Behavior changes

  • Long replies no longer close the session. Prism sends reply audio about 8.5× faster than real time, so the 256-chunk reply channel limit filled during long replies and closed the session mid-playback. Reply channels are now unbounded, like other realtime plugins, and truncated, interrupted, or closed-session replies drop their unread output (7b6606b, ee70ab4). Reported on feat(rime): add Prism realtime, speech recognition, and Coda lexicons agents-js#2866.
  • No plugin-side 4,000-character cap on history. update_chat_ctx() and typed input no longer reject messages over 4,000 characters; Prism enforces its own context limit.

Related SDK PR: rimelabs/rime-sdk#131

Validation

  • Local make check passed, including type checking of 813 source files. All 423 tests in tests/test_plugin_rime.py passed with the published SDK after merging current main.
  • The realtime and stt extras require published rimelabs-sdk>=0.1.0a30. The previous locked SDK lacked the new Prism types and behavior.
  • Production build 20261111 accepts the new settings. Full validation in a real LiveKit room remains pending.

Before release

Complete full end-to-end validation before release. This PR does not change package versions or the LiveKit Agents minimum.

SERVE-273 remains excluded.

@CLAassistant

CLAassistant commented Nov 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Disable AgentSession's AEC warmup in the direct and fallback Rime examples
so Prism receives caller audio from the start of agent speech. Document
how applications can retain an explicit warmup.

Cover caller audio forwarding and opening-greeting interruption through
both model paths, including the silence produced by an explicit warmup.

Co-authored by Codex 6 and augustohalvarez
Retain the upstream Rime test cleanup and SDK limit fixture alongside
the Prism settings and opening-greeting interruption regressions.

Co-authored by Codex 6 and augustohalvarez
Remove the adapter's 4,000-character cap and its obsolete validation
bypass. Retain role, content, and UTF-8 validation and preserve confirmed
history when the server refuses an update.

Cover long messages at startup, on update, across restarts, and through
direct and fallback agent replies. Document the server's context limit.

Co-authored by Codex 6 and augustohalvarez
@naszzz
naszzz marked this pull request as ready for review November 12, 2026 16:25
@naszzz
naszzz requested a review from a team as a code owner November 12, 2026 16:25
devin-ai-integration[bot]

This comment was marked as resolved.

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hi, thanks for the PR! few notes:

  • left a comment about checking speed up front
  • could we update the remaining a29 mentions in the readme? the long-tasks section still says the realtime extra requires alpha29
  • left a question about recommending aec_warmup_duration=None

Comment on lines +264 to +267
if is_given(speed):
self._speed = speed
if is_given(turn_detection):
self._merge_turn_update(turn_detection)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we validate speed (0.85 to 1.3) here and in the constructor? otherwise a bad value only fails at connect, which isn't retryable and ends the session

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in a9e0c07. Speed is now checked in the constructor and in update_options.

self.emit("input_speech_stopped", stopped)
elif isinstance(payload, r.TranscriptDelta):
text = self._transcript_deltas.get(payload.item_id, "") + payload.delta
cumulative = getattr(payload, "transcript", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i don't think we need getattr here

Suggested change
cumulative = getattr(payload, "transcript", None)
cumulative = payload.transcript

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in a9e0c07.

It requests interruption on caller speech. Early speech hints do not change
playback volume. There is no custom per-response interruption policy.

Set `aec_warmup_duration=None` on `AgentSession` so Prism receives caller audio

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we keep the default warmup in the snippets? turning it off lets the greeting's echo reach prism on speakerphone or sip, maybe we could just mention the tradeoff here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in a9e0c07. The snippets keep the default warmup, and the README explains the tradeoff.

- Validate realtime speed (0.85 to 1.3) in the constructor and both
  update_options paths, so a bad value fails immediately instead of at
  connect.
- Read TranscriptDelta.transcript directly; the SDK minimum provides it.
- Require rimelabs-sdk>=0.1.0a30 for the stt extra too, and update the
  README SDK and LiveKit minimums to match the declared dependencies.
- Keep LiveKit's default AEC warmup in the README snippets and document
  the early-interruption versus echo tradeoff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naszzz

naszzz commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, all addressed in a9e0c07. I also raised the stt extra to SDK a30, so no a29 mentions remain.

@naszzz
naszzz requested a review from tinalenguyen November 17, 2026 16:08
naszzz and others added 2 commits November 18, 2026 08:57
Resolve the rime pyproject.toml conflict by keeping main's
livekit-agents>=1.8.12 floor alongside this branch's
rimelabs-sdk>=0.1.0a30 requirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prism sends reply audio about 8.5x faster than real time, so a long reply
read at playback pace exceeded the 256-chunk reply channel limit and closed
the session. Reply text and audio channels now have no limit, like other
realtime plugins. Truncated and interrupted replies drop their unread output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@naszzz

naszzz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Also fixes a long-reply bug Tina raised on livekit/agents-js#2866: Prism sends reply audio about 8.5× faster than real time, so the 256-chunk reply channel limit closed the session during playback. Reply channels now have no limit, like other realtime plugins, and truncated or interrupted replies drop their unread output (7b6606b).

Keep main's livekit-agents>=1.9.1 floor alongside the rimelabs-sdk>=0.1.0a30
requirement. Stop the Rime README from naming a LiveKit minimum that goes
stale with each release; point to the declared requirement instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Reply channels are unbounded since long replies arrive faster than playback,
and the model keeps a reference to its closed session. Shutdown closed the
channels of completed replies without draining them, so their unread audio
and text stayed in memory. Shutdown now discards every reply's queued output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for the updates! few more notes:

  • left a comment about unread reply audio now that the channels are unbounded
  • left a small one about update_options applying some settings before it raises
  • could we clean up the install/compat section in the readme? left a comment there

Comment on lines +353 to +354
text: utils.aio.Chan[str] = field(default_factory=utils.aio.Chan)
audio: utils.aio.Chan[rtc.AudioFrame] = field(default_factory=utils.aio.Chan)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with these unbounded, a long reply that finished generating but never plays (interrupted before playback, or a session with no audio output) keeps its audio until 128 newer replies evict it, since interrupt() only handles the active one. maybe we could discard unread output of earlier ended generations when a new response starts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 15935f9. I didn't discard on new responses, since Prism sends audio about 8.5× faster than real time, so a finished reply can still be playing. Instead, the session drops its references when a reply ends, like the OpenAI plugin, and a reply LiveKit skips is freed with it. Against live Prism, unplayed audio went to 0 s and playing replies stayed intact.

Comment on lines +265 to +266
if is_given(speed):
_validate_speed(speed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we check the turn_detection type here too, next to _validate_speed? with no session, a full TurnDetection raises only after voice/speed/etc. are already stored

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in c2354d9. Both update_options methods now check the type next to _validate_speed, so a rejected call stores and queues nothing. This also stops a live session from sending a full TurnDetection to Prism before raising.

```sh
uv pip install --no-sources 'livekit-agents==1.7.1' \
uv pip install --no-sources 'livekit-agents==<version>' \
'livekit-plugins-rime[realtime] @ git+https://github.com/naszzz/agents.git@<commit>#subdirectory=livekit-plugins/livekit-plugins-rime'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we drop the install-from-fork snippet and the 1.7.1/1.8.x + a28 checks above (line 283)? the package now needs livekit-agents>=1.9.1 and rimelabs-sdk>=0.1.0a30, so those claims would ship stale

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 07a316d. I removed the fork snippet, the 1.7.1/1.8.x and a28 checks, and the notes about versions below 1.9.1.

naszzz and others added 3 commits December 3, 2026 19:20
…ttings

update_options checked the turn_detection type only while merging it. With
no session, voice, speed, and other settings were already stored when a full
TurnDetection raised. With a live session, the bad value was queued and failed
later as an error event. Both update_options methods now check the type next to
the speed check, so a rejected call changes and queues nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… README

The package now requires livekit-agents>=1.9.1 and rimelabs-sdk>=0.1.0a30.
Remove the install-from-fork snippet, the 1.7.1 and 1.8.x checks with a28, and
the notes about versions below the floor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session keeps up to 128 finished replies, and each one held its message
channels, message stream, and created event. A reply that finished generating
but never played, such as one interrupted before playback or in a session with
no audio output, kept its unread audio until newer replies evicted it.

The session now drops those references when a reply ends, as the OpenAI,
Google, and AWS realtime sessions do. LiveKit's own reference keeps a reply it
is still playing, so nothing is cut off, and a reply it skips is freed with it.
A requested reply's event is held only until generate_reply returns it.

Released channels stay weakly referenced, so truncation and shutdown still drop
unread output right away, including after the reply ended. A requested reply
whose request was cancelled before Prism acknowledged it is still held until
eviction; the README notes this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

4 participants