Skip to content

fix(liveavatar): honor agent.state_updated for speaking and barge-in - #7245

Open
cpruijsen wants to merge 1 commit into
livekit:mainfrom
cpruijsen:fix/issue-7232
Open

fix(liveavatar): honor agent.state_updated for speaking and barge-in#7245
cpruijsen wants to merge 1 commit into
livekit:mainfrom
cpruijsen:fix/issue-7232

Conversation

@cpruijsen

Copy link
Copy Markdown

Summary

agent.state_updated with new_state == "talking" follows the existing speak-started path; leaving talking (idle / listening) follows speak-ended. speak_* still work and are idempotent if a session emits both. Buffer append/commit are treated as command acks, not playback lifecycle. agent.audio_buffer_cleared is treated as the interrupt ack. error / warning are logged at the matching level.

LiveAvatar LITE emits agent.state_updated (idle / listening / talking) and agent.audio_buffer_* acks during a conversation. The plugin only handled session.state_updated and agent.speak_*, so _avatar_speaking never became true, playback start/finish were never notified from the server, and barge-in skipped agent.interrupt.

Decision

Speaking and playback are driven from agent.state_updated, not audio_buffer_appended β†’ started and audio_buffer_committed β†’ ended (the mapping sketched in the issue). The LITE events spec defines buffer events as command acks and agent.state_updated as the avatar speaking signal; the reporter also observed agent.state_updated on a real sandbox session. Mapping commit to "playback finished" would end playout on the speak_end ack, which can fire while the avatar is still talking. Can switch if append/commit should own playback instead.

Fixes #7232

Test plan

  • Unit tests in tests/test_plugin_liveavatar.py (pytest.mark.unit): agent.state_updated talking/listening updates _avatar_speaking and playback notifications; buffer append/commit do not; speak_started + talking is one playback-started; barge-in sends agent.interrupt after talking and does not after append-only.
  • Those tests fail without the dispatch change (5 failed, 4 passed) and pass with it, plus existing livekit-plugins/livekit-plugins-liveavatar/tests/test_api.py.
  • Live LITE/sandbox conversation with LIVEAVATAR_API_KEY / LIVEAVATAR_AVATAR_ID: DEBUG should no longer print Unhandled for agent.state_updated / agent.audio_buffer_*, and interrupting mid-reply should send agent.interrupt.

The LITE server now reports avatar state via agent.state_updated; ignoring it left _avatar_speaking false so agent.interrupt never reached the server.
@cpruijsen
cpruijsen requested a review from a team as a code owner September 12, 2026 08:41

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

1 flag not posted on this PR by your GitHub settings β€” view it in Devin Review. (Configure)

Devin Review

Comment on lines +383 to +384
elif event_type == "error":
logger.error(f"LiveAvatar error: {event.get('error', event)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟨 Provider errors leak customer content

An error event logs its full provider payload. Customer content in the error message bypasses structured PII redaction.

Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Comment on lines +385 to +386
elif event_type == "warning":
logger.warning(f"LiveAvatar warning: {event.get('warning', event)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟨 Provider warnings leak customer content

A warning event logs its full provider payload. Customer content in the warning bypasses structured PII redaction.

Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

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.

liveavatar plugin doesn't recognize agent.audio_buffer_* / agent.state_updated events from the LiveAvatar server (v1.8.0)

1 participant