Skip to content

fix(voice): restrict stt pipeline reuse to default stt_node#5803

Open
longcw wants to merge 2 commits into
mainfrom
longc/stt-pipeline-reuse-default-only
Open

fix(voice): restrict stt pipeline reuse to default stt_node#5803
longcw wants to merge 2 commits into
mainfrom
longc/stt-pipeline-reuse-default-only

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented May 22, 2026

Summary

On agent handoff, _detach_reusable_resources reuses the STT pipeline when type(self.agent).stt_node is type(new_activity.agent).stt_node. That check passes whenever two agents share the same stt_node method object — including via a common base class — but the detached pipeline is a running generator bound to the old agent's self. The default Agent.stt_node is safe because it only reads self/activity at startup, before the yield loop. Any custom override that touches self.session or self.activity inside the loop will crash after handoff:

File "/code/ai_receptionist/logic/livekit_agents/base.py", line 1079, in stt_node
    self.session,
File ".../voice/agent.py", line 684, in session
    return self._get_activity_or_raise().session
File ".../voice/agent.py", line 382, in _get_activity_or_raise
    raise RuntimeError("no activity context found, the agent is not running")

Tighten the precondition to "both agents use Agent.stt_node directly." Custom overrides — even ones shared via inheritance — no longer trigger reuse, since we can't verify they're safe to keep iterating after their bound self loses its activity.

@chenghao-mou chenghao-mou requested a review from a team May 22, 2026 00:33
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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