Skip to content

fix(voice): make function call history preservation configurable in AgentTask#5288

Open
GopalGB wants to merge 1 commit intolivekit:mainfrom
GopalGB:fix/agent-task-configurable-function-call-merge
Open

fix(voice): make function call history preservation configurable in AgentTask#5288
GopalGB wants to merge 1 commit intolivekit:mainfrom
GopalGB:fix/agent-task-configurable-function-call-merge

Conversation

@GopalGB
Copy link
Copy Markdown

@GopalGB GopalGB commented Mar 31, 2026

Summary

  • Adds preserve_function_call_history parameter to AgentTask.__init__() (default False for backward compatibility)
  • When True, function call and function call output items from the sub-task's chat context are retained when merging back to the parent agent
  • Previously, exclude_function_call=True was hardcoded, unconditionally stripping all tool call history

Root Cause

In AgentTask.__await_impl, the merge call:

old_agent.chat_ctx.merge(self.chat_ctx, exclude_function_call=True, ...)

unconditionally strips all function_call items. Users who need tool call results for context continuity (e.g., MCP tool responses, API lookups) had no way to preserve them.

Test Plan

  • Default behavior unchanged (preserve_function_call_history=False)
  • New parameter correctly inverts exclude_function_call flag
  • Backward compatible — no changes to existing call sites

Fixes #5284

…gentTask

AgentTask.__await_impl previously hardcoded exclude_function_call=True
when merging the sub-task's chat context back into the parent agent.
This unconditionally stripped all function_call and function_call_output
items, causing tool call results to be lost after task completion.

Adds a preserve_function_call_history parameter (default False for
backward compatibility) that controls whether function call history
from the sub-task is retained in the parent's chat context.

Fixes livekit#5284
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@GopalGB
Copy link
Copy Markdown
Author

GopalGB commented Mar 31, 2026

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AgentTask hardcodes exclude_function_call=True when merging chat context back to parent agent, causing loss of tool call history

2 participants