feat: Add ability to set custom clock and UUID providers#964
Open
DABH wants to merge 6 commits into
Open
Conversation
…ent creation Introduce a platform package whose current time and UUID generation can be overridden per-context, mirroring the ContextVar-based seams in ADK-Python: - platform.Now(ctx) / platform.WithTimeProvider(ctx, fn) - platform.NewUUID(ctx) / platform.WithUUIDProvider(ctx, fn) Both fall back to time.Now and uuid.NewString when no provider is installed, so default behavior is unchanged. session.NewEvent now takes a context and sources its ID and timestamp from these seams, and all event/session creation call sites are threaded with context accordingly. This lets a host runtime make event and session creation deterministic and replay-safe (e.g. a Temporal workflow that must reproduce an execution exactly on replay).
xumaple
reviewed
Jun 4, 2026
xumaple
reviewed
Jun 4, 2026
xumaple
reviewed
Jun 5, 2026
brianstrauch
reviewed
Jun 5, 2026
d7e7e50 to
6acb142
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Testing Plan
Unit Tests:
Please include a summary of passed go test results.
Full
go test ./... runon the branch yields 55 passed, 1 failed. The failure is identical to a failure occurring onmainright now and seems unrelated to the changes in this branch.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
A representative E2E test is here: https://gist.github.com/DABH/91c0d0a45788b4e152d53ca175b92980 . You can run this
go run .and get e.g.which demonstrates that all the plumbing in the PR works as expected (we inject deterministic providers and get the same output on each run). You can replace
deterministicCtx(context.Background())withcontext.Background()in that test file to see the results diverge (matching the current/default ADK behavior).Checklist
Additional Information
The
platformnaming here mimics what's inadk-python(google.adk.platform.time/google.adk.platform.uuid), but open to other naming based on feedback. My goal was to try to make things as close toadk-pythonas possible with this attempt.One important callout is a proposed breaking change for
session.NewEvent- adding a context variable as a first parameter. It's possible to avoid this (haveNewEventstay as-is and have it callNewEventWithContext(context.Background() ...), but modifyingNewEventseemed cleaner. Let me know what you think.