Skip to content

Conversation

toubatbrian
Copy link
Contributor

@toubatbrian toubatbrian commented Sep 24, 2025

Description

Resolve race condition of having generateReply inside tool call.

Changes Made

Always wait for all generateReply inside tool call to be scheduled first, before dispatching the speech handle of the tool response

Pre-Review Checklist

  • Build passes: All builds (lint, typecheck, tests) pass locally
  • AI-generated code reviewed: Removed unnecessary comments and ensured code quality
  • Changes explained: All changes are properly documented and justified above
  • Scope appropriate: All changes relate to the PR title, or explanations provided for why they're included

Testing

  • Automated tests added/updated (if applicable)
  • All tests pass
  • Make sure both restaurant_agent.ts and realtime_agent.ts work properly (for major changes)

Copy link

changeset-bot bot commented Sep 24, 2025

⚠️ No Changeset found

Latest commit: 1eeb3fd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

export function createActiveToolCall(functionCall: FunctionCall): ActiveToolCall {
return {
functionCall,
speechHandles: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We keep track of all generateReply created inside tool call so we can wait them to be scheduled

Copy link
Contributor

@Shubhrakanti Shubhrakanti left a comment

Choose a reason for hiding this comment

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

  1. Can you add why the race condition was happening in the first place?
  2. This solution seems to diverge from the python implementation? Is there a way we can solve this similar to how the python side does it?

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.

2 participants