Skip to content

Commit

Permalink
fix context when functions have been called (#1279)
Browse files Browse the repository at this point in the history
Co-authored-by: David Zhao <[email protected]>
  • Loading branch information
jmugicagonz and davidzhao authored Dec 23, 2024
1 parent 42b0e68 commit c7881f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-fishes-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-agents": patch
---

fix context when functions have been called
5 changes: 5 additions & 0 deletions livekit-agents/livekit/agents/pipeline/pipeline_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ async def _synthesize_answer_task(
not playing_speech.user_question or playing_speech.user_committed
) and not playing_speech.speech_committed:
# the speech is playing but not committed yet, add it to the chat context for this new reply synthesis
# First add the previous function call message if any
if playing_speech.extra_tools_messages:
copied_ctx.messages.extend(playing_speech.extra_tools_messages)

# Then add the previous assistant message
copied_ctx.messages.append(
ChatMessage.create(
text=playing_speech.synthesis_handle.tts_forwarder.played_text,
Expand Down

0 comments on commit c7881f3

Please sign in to comment.