Skip to content

Conversation

@krishna-dhulipalla
Copy link
Contributor

Problem

The example in contributing/samples/human_in_loop/README.md shows:

await runner.run_async(...)

However, run_async returns an async generator, so awaiting it raises:

TypeError: object async_generator can't be used in 'await' expression

Additionally, the example payload uses "ticket-id" while ADK tools and other examples use "ticketId", creating a mismatch that breaks copy/paste usage.

Solution

  • Updated the snippet to consume the async generator correctly:
async for event in runner.run_async(...):
    ...
  • Aligned the payload key from "ticket-id""ticketId" for consistency with ADK schema and other examples.

These changes make the example runnable and consistent with the API’s actual behavior.

Testing Plan

This PR is a small documentation correction, so no unit tests are required per contribution guidelines.

  • Verified the corrected snippet manually to ensure it no longer raises TypeError.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas. (N/A – docs only)
  • I have added tests that prove my fix is effective or that my feature works. (N/A – docs only)
  • New and existing unit tests pass locally with my changes. (N/A – docs only)
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (N/A)

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @krishna-dhulipalla, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two critical documentation issues within the human_in_loop example. It corrects the usage of an async generator to properly iterate over its events and standardizes a payload key for consistency across the ADK ecosystem. These changes ensure the example is runnable, accurate, and aligned with the API's intended behavior.

Highlights

  • Fix run_async example usage: The example in contributing/samples/human_in_loop/README.md incorrectly awaited runner.run_async directly. Since run_async returns an async generator, the snippet has been updated to correctly consume it using async for to prevent a TypeError.
  • Correct ticketId payload key: The payload key for ticket-id has been standardized to ticketId in the example to ensure consistency with ADK tools, schema, and other examples, preventing mismatches and improving copy-paste usability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the documentation [Component] This issue is related to documentation, it will be transferred to adk-docs label Dec 9, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-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.

Code Review

This pull request correctly addresses two issues in the human_in_loop sample documentation. Changing "ticket-id" to "ticketId" ensures consistency with the rest of the ADK, and fixing the run_async example to correctly consume the async generator makes the documentation runnable and accurate. These are valuable improvements. I've added one suggestion to make the code example slightly more illustrative for new users.

@ryanaiagent ryanaiagent self-assigned this Dec 9, 2025
@seanzhou1023 seanzhou1023 added the ready to pull [Status] This PR is ready to be importing back to Google label Dec 9, 2025
copybara-service bot pushed a commit that referenced this pull request Dec 11, 2025
Merge #3875

# Problem
The example in `contributing/samples/human_in_loop/README.md` shows:

```python
await runner.run_async(...)
```

However, `run_async` returns an **async generator**, so awaiting it raises:

```
TypeError: object async_generator can't be used in 'await' expression
```

Additionally, the example payload uses `"ticket-id"` while ADK tools and other examples use `"ticketId"`, creating a mismatch that breaks copy/paste usage.

# Solution
- Updated the snippet to consume the async generator correctly:

```python
async for event in runner.run_async(...):
    ...
```

- Aligned the payload key from `"ticket-id"` → `"ticketId"` for consistency with ADK schema and other examples.

These changes make the example runnable and consistent with the API’s actual behavior.

# Testing Plan
This PR is a **small documentation correction**, so no unit tests are required per contribution guidelines.

- Verified the corrected snippet manually to ensure it no longer raises `TypeError`.

# Checklist
- [x] I have read the CONTRIBUTING.md document.
- [x] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas. *(N/A – docs only)*
- [ ] I have added tests that prove my fix is effective or that my feature works. *(N/A – docs only)*
- [ ] New and existing unit tests pass locally with my changes. *(N/A – docs only)*
- [x] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules. *(N/A)*

COPYBARA_INTEGRATE_REVIEW=#3875 from krishna-dhulipalla:docs/fix-adk-run_async-example 83fc5b4
PiperOrigin-RevId: 842952362
@adk-bot
Copy link
Collaborator

adk-bot commented Dec 11, 2025

Thank you @krishna-dhulipalla for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 4111f85.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot closed this Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation [Component] This issue is related to documentation, it will be transferred to adk-docs ready to pull [Status] This PR is ready to be importing back to Google

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants