Skip to content

Commit 28c15b9

Browse files
Panmaxjiapan
authored andcommitted
refactor(agent_session): simplify generate_reply logic during scheduling pause
1 parent 2400e34 commit 28c15b9

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
@@ -827,22 +827,12 @@ def generate_reply(
827827
)
828828

829829
run_state = self._global_run_state
830-
if self._activity.scheduling_paused:
831-
if self._next_activity is None:
832-
raise RuntimeError("AgentSession is closing, cannot use generate_reply()")
833-
834-
handle = self._next_activity._generate_reply(
835-
user_message=user_message,
836-
instructions=instructions,
837-
tool_choice=tool_choice,
838-
allow_interruptions=allow_interruptions,
839-
)
840-
if run_state:
841-
run_state._watch_handle(handle)
842830

843-
return handle
831+
activity = self._next_activity if self._activity.scheduling_paused else self._activity
832+
if activity is None:
833+
raise RuntimeError("AgentSession is closing, cannot use generate_reply()")
844834

845-
handle = self._activity._generate_reply(
835+
handle = activity._generate_reply(
846836
user_message=user_message,
847837
instructions=instructions,
848838
tool_choice=tool_choice,

0 commit comments

Comments
 (0)