Skip to content

Commit 2f5e54d

Browse files
authored
remove duplicated message (#1363)
1 parent ab90fd2 commit 2f5e54d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

livekit-agents/livekit/agents/pipeline/pipeline_agent.py

+6
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ async def _synthesize_answer_task(
721721
# the speech is playing but not committed yet, add it to the chat context for this new reply synthesis
722722
# First add the previous function call message if any
723723
if playing_speech.extra_tools_messages:
724+
if playing_speech.fnc_text_message_id is not None:
725+
# there is a message alongside the function calls
726+
msgs = copied_ctx.messages
727+
if msgs and msgs[-1].id == playing_speech.fnc_text_message_id:
728+
# replace it with the tool call message if it's the last in the ctx
729+
msgs.pop()
724730
copied_ctx.messages.extend(playing_speech.extra_tools_messages)
725731

726732
# Then add the previous assistant message

0 commit comments

Comments
 (0)