Skip to content
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: starter pack live api async tool calls #1679

Conversation

eliasecchig
Copy link
Contributor

With the help of kwn@ who raised this bug via mail

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

Hi team,

I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly understand the changes:

This pull request addresses a bug reported by kwn@ (thanks kwn!), focusing on improving the asynchronous handling of tool calls within the e2e-gen-ai-app-starter-pack's live agent functionality. The core changes are:

  • agent.py (lines 48-58): The retrieve_docs function, responsible for retrieving documents, has been made asynchronous using async. A helpful warning was also added to inform the user about potential delays.
  • server.py (lines 18-41): Import statements were reorganized for better readability and maintainability.
  • server.py (lines 93-142): The _handle_tool_call function was refactored to use asyncio.create_task for concurrent processing of tool calls, enhancing responsiveness. Error handling was also improved with a try...except block to catch and log exceptions during tool call processing and Gemini message reception. The receive_from_gemini function now sends messages to the client immediately and processes tool calls asynchronously to prevent blocking.

The overall intent is to make the live agent more responsive and robust by handling asynchronous operations efficiently and gracefully managing potential errors.


Here's a little haiku to lighten the mood:

Async calls now fly,
Errors caught, the agent waits,
Smooth responses flow.

Let me know if you have any questions. I'll post my full review soon!

Best,
Gemini/code-review-assist

Copy link
Contributor

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

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

This pull request aims to fix asynchronous tool calls in the starter pack. The changes correctly implement the async functionality for the retrieve_docs function and handle the responses in the server. However, there are some minor improvements that can be made for clarity and maintainability.

I have referenced elements from the PEP 8 style guide in this review, particularly around documentation string style.

@eliasecchig eliasecchig marked this pull request as ready for review January 31, 2025 18:34
@eliasecchig eliasecchig requested a review from a team as a code owner January 31, 2025 18:34
@eliasecchig eliasecchig enabled auto-merge (squash) January 31, 2025 18:36
@eliasecchig eliasecchig merged commit 8bf920d into GoogleCloudPlatform:main Jan 31, 2025
7 checks passed
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