- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.2k
Description
Description of the feature request:
I'd like to propose adding a new example notebook to the examples/google-adk/ directory (assuming #709 is planned). This notebook would demonstrate a more advanced integration pattern, showcasing how to manage asynchronous background tasks using Google ADK, triggered and monitored through a conversational interface powered by the google-genai SDK.
What problem are you trying to solve with this feature?
Currently, standard function calling with google-genai is synchronous. Many real-world applications require initiating long-running background processes without blocking the main user conversation. Users expect to continue interacting with the assistant while these tasks are completed and potentially query their status later. This example would provide a clear pattern for achieving this responsiveness using ADK for the task orchestration layer.
Any other information you'd like to share?
Proposed Scenario & Workflow
The notebook would implement the "Asynchronous Query Handling Process" (similar to the diagram discussed/provided):
- User Interaction: A user interacts with a primary assistant interface built using the google-genaiSDK.
- Task Initiation: The user asks the assistant to perform a long-running task (e.g., "Find details about X in the database").
- GenAI Interpretation & ADK Trigger: The google-genaiassistant interprets the command and calls a synchronous ADKFunctionTool(start_long_query).
- ADK Tool Action (Initiate & Return): This ADK tool executes quickly:
- Generates a unique job_id.
- Uses asyncio.create_task()to schedule the actual long-running async function (run_actual_query_async) to execute concurrently in the background. This background function will contain the simulated work (e.g.,await asyncio.sleep()) and logic to update a shared state store.
- Immediately records the initial 'PENDING' status for the job_idin a simulated Shared State Store (e.g., a Python dictionary).
- Immediately returns {'status': 'success', 'job_id': 'job_id'}back to thegoogle-genaiassistant.
 
- Generates a unique 
- User Confirmation: The google-genaiassistant confirms task initiation ("Okay, I've started jobjob-123...") and is immediately ready for the next user message.
- Background Processing (Asyncio Task): The asynciotask (run_actual_query_async) runs independently: updates status to 'RUNNING' in the state store, performs simulated work, updates status to 'COMPLETED'/'FAILED', and stores results/errors in the state store.
- Ongoing Interaction: User can continue chatting or initiate new background tasks (each creating its own asynciotask).
- Status Check: User asks for the status of job-123.
- GenAI Interpretation & ADK Query: Assistant calls a second synchronous ADK FunctionTool(check_query_status).
- ADK Tool Action (Query): This tool queries the simulated Shared State Store for the status/results of the job_id.
- Report Status: The google-genaiassistant relays the retrieved status/results to the user.
Benefits:
- Provides a practical pattern for responsive, long-running task initiation via chat.
- Shows how ADK tools can integrate with Python's asynciofor background processing.
- Demonstrates synergy between google-genaiandgoogle-adk.
