Skip to content

Commit

Permalink
Do not pass function context if at max depth (#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-purplefish authored Dec 29, 2024
1 parent 97d9bce commit bd36bc9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/khaki-candles-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-agents": patch
---

Do not pass function context if at max depth
19 changes: 18 additions & 1 deletion livekit-agents/livekit/agents/pipeline/pipeline_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,24 @@ async def _execute_function_calls() -> None:
chat_ctx = call_ctx.chat_ctx.copy()
chat_ctx.messages.extend(extra_tools_messages)
chat_ctx.messages.extend(call_ctx.extra_chat_messages)
answer_llm_stream = self._llm.chat(chat_ctx=chat_ctx, fnc_ctx=self.fnc_ctx)
fnc_ctx = self.fnc_ctx
if (
fnc_ctx
and new_speech_handle.fnc_nested_depth
>= self._opts.max_nested_fnc_calls
):
logger.warning(
"max function calls nested depth reached, not propagating fnc ctx",
extra={
"speech_id": speech_handle.id,
"fnc_nested_depth": speech_handle.fnc_nested_depth,
},
)
fnc_ctx = None
answer_llm_stream = self._llm.chat(
chat_ctx=chat_ctx,
fnc_ctx=fnc_ctx,
)

synthesis_handle = self._synthesize_agent_speech(
new_speech_handle.id, answer_llm_stream
Expand Down

0 comments on commit bd36bc9

Please sign in to comment.