Skip to content

Commit a641aa0

Browse files
authored
Unify generate_reply and say code pattern (livekit#3683)
1 parent c5cbb22 commit a641aa0

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

livekit-agents/livekit/agents/voice/agent_session.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -830,22 +830,12 @@ def generate_reply(
830830
)
831831

832832
run_state = self._global_run_state
833-
if self._activity.scheduling_paused:
834-
if self._next_activity is None:
835-
raise RuntimeError("AgentSession is closing, cannot use generate_reply()")
836-
837-
handle = self._next_activity._generate_reply(
838-
user_message=user_message,
839-
instructions=instructions,
840-
tool_choice=tool_choice,
841-
allow_interruptions=allow_interruptions,
842-
)
843-
if run_state:
844-
run_state._watch_handle(handle)
833+
activity = self._next_activity if self._activity.scheduling_paused else self._activity
845834

846-
return handle
835+
if activity is None:
836+
raise RuntimeError("AgentSession is closing, cannot use generate_reply()")
847837

848-
handle = self._activity._generate_reply(
838+
handle = activity._generate_reply(
849839
user_message=user_message,
850840
instructions=instructions,
851841
tool_choice=tool_choice,

0 commit comments

Comments
 (0)