Skip to content

Commit 025615d

Browse files
committed
refactor(runner): simplify rewind receipt construction
1 parent 1ef8763 commit 025615d

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/google/adk/runners.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -649,29 +649,25 @@ def _build_rewind_audit_receipt(
649649
receipt_hash = self._hash_rewind_payload(receipt_payload)
650650

651651
return RewindAuditReceipt(
652-
rewind_before_invocation_id=rewind_before_invocation_id,
653-
boundary_after_invocation_id=boundary_after_invocation_id,
654-
events_before_rewind=len(events_before),
655-
events_after_rewind=len(events_after),
656-
history_before_hash=history_before_hash,
657-
history_after_hash=history_after_hash,
652+
**receipt_payload,
658653
receipt_hash=receipt_hash,
659654
)
660655

661656
def _hash_rewind_events(self, events: List[Event]) -> str:
662657
"""Hashes event summaries for deterministic rewind audit receipts."""
663-
summarized_events = []
664-
for event in events:
665-
summarized_events.append({
666-
'event_id': event.id,
667-
'invocation_id': event.invocation_id,
668-
'author': event.author,
669-
'state_delta': event.actions.state_delta,
670-
'artifact_delta': event.actions.artifact_delta,
671-
'rewind_before_invocation_id': (
672-
event.actions.rewind_before_invocation_id
673-
),
674-
})
658+
summarized_events = [
659+
{
660+
'event_id': event.id,
661+
'invocation_id': event.invocation_id,
662+
'author': event.author,
663+
'state_delta': event.actions.state_delta,
664+
'artifact_delta': event.actions.artifact_delta,
665+
'rewind_before_invocation_id': (
666+
event.actions.rewind_before_invocation_id
667+
),
668+
}
669+
for event in events
670+
]
675671
return self._hash_rewind_payload({'events': summarized_events})
676672

677673
def _hash_rewind_payload(self, payload: dict[str, Any]) -> str:

0 commit comments

Comments
 (0)