Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion livekit-agents/livekit/agents/voice/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ def __init__(
llm: NotGivenOr[llm.LLM | llm.RealtimeModel | None] = NOT_GIVEN,
tts: NotGivenOr[tts.TTS | None] = NOT_GIVEN,
mcp_servers: NotGivenOr[list[mcp.MCPServer] | None] = NOT_GIVEN,
merge_exclude_function_call: bool = True, # if True, exclude function calls when merging context to parent
# deprecated
turn_detection: NotGivenOr[TurnDetectionMode | None] = NOT_GIVEN,
allow_interruptions: NotGivenOr[bool] = NOT_GIVEN,
Expand Down Expand Up @@ -733,6 +734,7 @@ def __init__(
self.__fut = asyncio.Future[TaskResult_T]()
self.__inactive_ev = asyncio.Event()
self.__inactive_ev.set() # set when the agent is not awaited or activity is closed
self._merge_exclude_function_call = merge_exclude_function_call

self._old_agent: Agent | None = None

Expand Down Expand Up @@ -892,7 +894,7 @@ def _handle_task_done(_: asyncio.Task[Any]) -> None:
run_state._watch_handle(speech_handle)

merged_chat_ctx = old_agent.chat_ctx.merge(
self.chat_ctx, exclude_function_call=True, exclude_instructions=True
self.chat_ctx, exclude_function_call=self._merge_exclude_function_call, exclude_instructions=True
)
# set the chat_ctx directly, `session._update_activity` will sync it to the rt_session if needed
old_agent._chat_ctx.items[:] = merged_chat_ctx.items
Expand Down
Loading