Skip to content

Commit b4c2b4d

Browse files
committed
refactor(runner): simplify rewind receipt construction
1 parent e9dc2b2 commit b4c2b4d

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

src/google/adk/runners.py

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

648648
return RewindAuditReceipt(
649-
rewind_before_invocation_id=rewind_before_invocation_id,
650-
boundary_after_invocation_id=boundary_after_invocation_id,
651-
events_before_rewind=len(events_before),
652-
events_after_rewind=len(events_after),
653-
history_before_hash=history_before_hash,
654-
history_after_hash=history_after_hash,
649+
**receipt_payload,
655650
receipt_hash=receipt_hash,
656651
)
657652

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

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

0 commit comments

Comments
 (0)