-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: empty agent transcript #1148
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"livekit-agents": patch | ||
--- | ||
|
||
fix: empty agent transcript |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -883,24 +883,25 @@ async def _execute_function_calls() -> None: | |
if interrupted: | ||
collected_text += "..." | ||
|
||
msg = ChatMessage.create(text=collected_text, role="assistant") | ||
self._chat_ctx.messages.append(msg) | ||
if collected_text: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When can this happen? I'm more worried about the cause than fixing the scenario where it is indeed empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This happens when agent finish speaking tool call's response. we get an extra empty transcript. screenshot Can there be a possiblity when llm response is just empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, I think we should add new arguments to the agent_speech_committed event. I think it is a valid usecase to have an empty content but having function calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something like below?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@theomonnom wouldn't that break existing callbacks? I'm not sure if there's value in it because function calls are supposed to be handled by the framework There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will think more about that alongside the new IO proposal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put this PR in standby for now, we should be able to add new arguments without breaking |
||
msg = ChatMessage.create(text=collected_text, role="assistant") | ||
self._chat_ctx.messages.append(msg) | ||
|
||
speech_handle.mark_speech_committed() | ||
speech_handle.mark_speech_committed() | ||
|
||
if interrupted: | ||
self.emit("agent_speech_interrupted", msg) | ||
else: | ||
self.emit("agent_speech_committed", msg) | ||
if interrupted: | ||
self.emit("agent_speech_interrupted", msg) | ||
else: | ||
self.emit("agent_speech_committed", msg) | ||
|
||
logger.debug( | ||
"committed agent speech", | ||
extra={ | ||
"agent_transcript": collected_text, | ||
"interrupted": interrupted, | ||
"speech_id": speech_handle.id, | ||
}, | ||
) | ||
logger.debug( | ||
"committed agent speech", | ||
extra={ | ||
"agent_transcript": collected_text, | ||
"interrupted": interrupted, | ||
"speech_id": speech_handle.id, | ||
}, | ||
) | ||
|
||
# mark the speech as done | ||
speech_handle._set_done() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would skip
speech_handle.mark_speech_committed()
, do we want to mark it as committed before skipping the other operations?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model's response contains empty content when it responds with a tool call, should we still mark it as committed? because after executing function model will respond with string that will be marked as committed