-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: Add Temporal integration and deterministic runtime support #3920
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @marcusmotill, 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 significantly enhances the ADK by integrating with Temporal workflows, thereby addressing critical challenges related to determinism and I/O traceability in AI agent execution. It achieves this by introducing a new runtime abstraction that provides deterministic time and UUID generation, alongside a suite of helper classes that seamlessly bridge ADK agents and tools with Temporal activities. This ensures that all agent actions, including LLM calls and tool executions, are durably recorded and replayable within the Temporal Event History, facilitating robust and observable AI applications. Highlights
Using Gemini Code AssistThe 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
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 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
|
|
Response from ADK Triaging Agent Hello @marcusmotill, thank you for creating this PR! Your PR is missing unit tests. Could you please add unit tests for your change? You can add or update tests under This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this 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 introduces a significant and well-designed integration with Temporal to support deterministic execution of AI agents in workflows. The core of the change is the new runtime module, which correctly abstracts non-deterministic system calls like getting the time and generating UUIDs. The integration helpers in google.adk.integrations.temporal, such as TemporalModel and activity_as_tool, are powerful additions that make it much easier to run ADK agents within Temporal. The accompanying integration test is comprehensive and covers both single and multi-agent scenarios effectively.
My review includes a critical fix for argument handling when wrapping activities as tools to prevent potential bugs with keyword arguments, a suggestion to adhere to Python's import conventions, and a minor cleanup in the test code to remove an unused variable. Overall, this is an excellent contribution that greatly enhances the capabilities of the ADK.
c0fd751 to
1a63985
Compare
Description
This PR introduces first-class support for Temporal workflows within the ADK. It addresses the two main challenges of running AI agents in durable workflows: determinism and I/O traceability.
1. Deterministic Runtime (
google.adk.runtime)Introduced a new
runtimeabstraction to decouple the ADK from system time and random state.time.time()anduuid.uuid4()are non-deterministic, which breaks Temporal's replay mechanism.google.adk.runtimemodule.runtime.get_time(): Defaults to system time, but can be overridden (e.g., byworkflow.now().timestamp()).runtime.new_uuid(): Defaults touuid.uuid4(), but can be overridden (e.g., byworkflow.uuid4()).Event,InvocationContext, and InMemorySessionService now useruntimeinstead of direct system calls.2. Temporal Integration Helpers (
google.adk.integrations.temporal)Added helper classes to seamlessly bridge ADK Agents with Temporal Activities.
BaseLlmimplementation that wraps a Temporal Activity. This ensures all LLM calls are recorded in the Temporal Event History, providing visibility into the agent's "thinking" process.3. Multi-Agent & Serialization Support
pydanticserialization support for ADK objects passed between workflows and activities.Verification
Added a comprehensive manual integration test:
tests/integration/manual_test_temporal_integration.py.To Run:
temporal server start-dev).GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION).uv run pytest tests/integration/manual_test_temporal_integration.pyTest Scenarios Covered:
transfer_to_agent(Handoff), with each agent's actions clearly visible in the Temporal Trace via aliased activities (coordinator_think,tool_agent_think).