Commit 8126987
committed
feat: Add injectable time and UUID providers for deterministic runs
ADK generates timestamps and IDs by calling Instant.now() and
UUID.randomUUID() directly, which makes runs non-reproducible. A Temporal
integration (and any replay-based execution) needs these to be
deterministic so that re-executing the same invocation yields byte-identical
events. adk-python already supports this via platform.time/platform.uuid,
and adk-go has an equivalent seam.
Add a leaf com.google.adk.platform package with TimeProvider and
UuidProvider functional interfaces, each with a SYSTEM default that
preserves today's wall-clock/random behavior. Rather than an ambient
ThreadLocal (which would silently fall back to the system providers once
the RxJava flow hops onto a Schedulers worker thread), the providers are
threaded as data through InvocationContext, so they are visible on whatever
thread builds an event. Callers configure them once on the Runner.
Event ids and timestamps, the invocation id, function-call ids, and the
InMemorySessionService session id and lastUpdateTime now derive from the
in-scope providers. Event.generateEventId() and the build() timestamp
default remain as the non-deterministic fallback, so the Event API stays
non-breaking.1 parent ec93f50 commit 8126987
15 files changed
Lines changed: 564 additions & 29 deletions
File tree
- core/src
- main/java/com/google/adk
- agents
- flows/llmflows
- platform
- runner
- sessions
- test/java/com/google/adk
- agents
- flows/llmflows
- platform
- runner
- sessions
Lines changed: 67 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | | - | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
195 | 221 | | |
196 | 222 | | |
197 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
198 | 229 | | |
199 | 230 | | |
200 | 231 | | |
| |||
275 | 306 | | |
276 | 307 | | |
277 | 308 | | |
| 309 | + | |
| 310 | + | |
278 | 311 | | |
279 | 312 | | |
280 | 313 | | |
| |||
294 | 327 | | |
295 | 328 | | |
296 | 329 | | |
| 330 | + | |
| 331 | + | |
297 | 332 | | |
298 | 333 | | |
299 | 334 | | |
| |||
475 | 510 | | |
476 | 511 | | |
477 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
478 | 537 | | |
479 | 538 | | |
480 | 539 | | |
| |||
531 | 590 | | |
532 | 591 | | |
533 | 592 | | |
534 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
535 | 596 | | |
536 | 597 | | |
537 | 598 | | |
| |||
553 | 614 | | |
554 | 615 | | |
555 | 616 | | |
556 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
557 | 620 | | |
558 | 621 | | |
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
| 441 | + | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
| 464 | + | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
| 650 | + | |
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| |||
727 | 727 | | |
728 | 728 | | |
729 | 729 | | |
730 | | - | |
| 730 | + | |
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
| |||
772 | 772 | | |
773 | 773 | | |
774 | 774 | | |
775 | | - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
776 | 779 | | |
777 | 780 | | |
| 781 | + | |
778 | 782 | | |
779 | 783 | | |
780 | 784 | | |
| |||
794 | 798 | | |
795 | 799 | | |
796 | 800 | | |
797 | | - | |
| 801 | + | |
798 | 802 | | |
799 | 803 | | |
800 | 804 | | |
| |||
Lines changed: 30 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
| |||
104 | 121 | | |
105 | 122 | | |
106 | 123 | | |
107 | | - | |
| 124 | + | |
108 | 125 | | |
109 | 126 | | |
110 | 127 | | |
| |||
169 | 186 | | |
170 | 187 | | |
171 | 188 | | |
172 | | - | |
| 189 | + | |
173 | 190 | | |
174 | 191 | | |
175 | 192 | | |
| |||
233 | 250 | | |
234 | 251 | | |
235 | 252 | | |
236 | | - | |
| 253 | + | |
| 254 | + | |
237 | 255 | | |
238 | 256 | | |
239 | 257 | | |
| |||
492 | 510 | | |
493 | 511 | | |
494 | 512 | | |
495 | | - | |
| 513 | + | |
496 | 514 | | |
497 | 515 | | |
498 | 516 | | |
| |||
516 | 534 | | |
517 | 535 | | |
518 | 536 | | |
519 | | - | |
| 537 | + | |
520 | 538 | | |
521 | 539 | | |
522 | 540 | | |
| |||
667 | 685 | | |
668 | 686 | | |
669 | 687 | | |
670 | | - | |
| 688 | + | |
| 689 | + | |
671 | 690 | | |
672 | 691 | | |
673 | 692 | | |
| |||
712 | 731 | | |
713 | 732 | | |
714 | 733 | | |
715 | | - | |
| 734 | + | |
716 | 735 | | |
717 | 736 | | |
718 | 737 | | |
| |||
728 | 747 | | |
729 | 748 | | |
730 | 749 | | |
| 750 | + | |
| 751 | + | |
731 | 752 | | |
732 | 753 | | |
733 | 754 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments