Bulk request agents on the same runner #3438
-
|
Hi there! First of thanks for the community calls, great to see the people behind the scenes. I have a question about how to bulk request a root agent within the same runner. Usually, I’ve had use cases where I read a CSV (or similar) and then make a request for each row in the file. Using REST endpoints, this was pretty straightforward; however, I’m unsure if this is supported in ADK, and if so, how you would approach it. The reason I’m asking is that ADK seems tailored to chat applications with sessions. In this case, the use doesn’t require any context handling or content persistence, but I’d still like to use the framework to combine tools and other LLMs. Currently, I’m doing it like this: I create one runner and have a process_row_task function that creates a unique session for each request to avoid context conflicts. Then it runs runner.run_async and returns the results. Is there a smarter or better way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
Could it make sense to just have it hosted seperately instead? So have Cloud Run run the agents, tools etc and then have a simple Cloud function pull in csv data, then concurrently call the cloud run function so you basically call the agent like a rest endpoint? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Your current approach is a solid and recommended pattern for bulk processing of independent tasks in ADK. Creating a unique session for each task is the correct way to ensure context isolation. Hi there! Thanks for the great question and for sharing your approach. It's great to see how you're using ADK for different use cases. Your method of handling bulk requests is not only a valid way to approach this problem but is also aligned with the core design principles of ADK. Here’s a breakdown of why your approach is effective:
An alternative for some use cases is the So, to answer your question directly: your current method is a "smarter or better way to do this" for your use case. It correctly leverages ADK's asynchronous capabilities and session management to handle bulk, independent tasks efficiently. Keep up the great work! [1] https://google.github.io/adk-docs/runtime/ |
Beta Was this translation helpful? Give feedback.
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Your current approach for bulk processing by creating a new session for each row in your CSV is a great way to handle this in ADK. It's an idiomatic and effective pattern for ensuring stateless, parallel execution. Hi there! Thanks for the great question and for sharing your implementation. What you are doing is indeed a very effective and sound way to handle bulk, stateless requests with ADK. Here’s a bit more detail on why your approach is on the right track:
The alternative suggestion of deploying the agent as a separate service (e.g., on Cloud Run) and calling it via REST API is also a valid architectural pattern, especially for scalability and separating concerns. However, for processing within a single application runner, your current approach is efficient and well-designed. Keep up the great work! |
Beta Was this translation helpful? Give feedback.
Response from ADK Answering Agent (experimental, answer may be inaccurate)
TLDR: Your current approach is a solid and recommended pattern for bulk processing of independent tasks in ADK. Creating a unique session for each task is the correct way to ensure context isolation.
Hi there!
Thanks for the great question and for sharing your approach. It's great to see how you're using ADK for different use cases.
Your method of handling bulk requests is not only a valid way to approach this problem but is also aligned with the core design principles of ADK. Here’s a breakdown of why your approach is effective:
Asynchronous by Design: The ADK is built on
asyncio, andrunner.run_asyncis the pr…