Skip to content

Fix parallel tool handoff reply race - #7075

Open
sir-ad wants to merge 2 commits into
livekit:mainfrom
sir-ad:fix/parallel-tool-handoff
Open

Fix parallel tool handoff reply race#7075
sir-ad wants to merge 2 commits into
livekit:mainfrom
sir-ad:fix/parallel-tool-handoff

Conversation

@sir-ad

@sir-ad sir-ad commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • retain handoff results regardless of parallel tool completion order
  • suppress outgoing-agent replies while a handoff is pending in pipeline and realtime paths
  • preserve every parallel function call and output in agent context and session history

Fixes #5150

Problem

When one parallel tool returned an Agent and a sibling returned a reply-producing value, the outgoing activity could generate another response after initiating the handoff. That response could win the drain race, leaving the replacement agent inactive. A handoff result could also be overwritten when it appeared before a non-handoff result in the output batch.

The realtime path had the same ordering issue. It could additionally sync outputs to an outgoing session with automatic tool replies or schedule a local reply. The handoff now takes precedence in both paths while completed tool results remain recorded locally.

Verification

  • 120 focused pipeline, realtime, handoff, nested-task, interruption, and context-sync tests passed
  • realtime regression covers handoff-first and handoff-last order with automatic and manual tool-reply modes
  • make check

@sir-ad
sir-ad requested a review from a team as a code owner September 1, 2026 01:46
@CLAassistant

CLAassistant commented Sep 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T01:49:28.947566Z 1379b56 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

devin-ai-integration[bot]

This comment was marked as resolved.

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.

Agent handoff fails when tool returning Agent runs in parallel with reply-producing tool (pipeline path)

2 participants