Skip to content

Commit 2c08783

Browse files
committed
fix(runners): satisfy pyink and mypy-diff for rewind receipt
1 parent 3994a46 commit 2c08783

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/google/adk/events/event_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EventCompaction(BaseModel):
4747
"""The compacted content of the events."""
4848

4949

50-
class RewindAuditReceipt(BaseModel):
50+
class RewindAuditReceipt(BaseModel): # type: ignore[misc]
5151
"""Audit receipt metadata emitted for rewind operations."""
5252

5353
model_config = ConfigDict(

src/google/adk/runners.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -628,20 +628,20 @@ def _build_rewind_audit_receipt(
628628
events_after = session.events[:rewind_event_index]
629629
boundary_after_invocation_id = None
630630
if rewind_event_index > 0:
631-
boundary_after_invocation_id = (
632-
session.events[rewind_event_index - 1].invocation_id
633-
)
631+
boundary_after_invocation_id = session.events[
632+
rewind_event_index - 1
633+
].invocation_id
634634

635635
history_before_hash = self._hash_rewind_events(events_before)
636636
history_after_hash = self._hash_rewind_events(events_after)
637637

638638
receipt_payload = {
639-
'rewind_before_invocation_id': rewind_before_invocation_id,
640-
'boundary_after_invocation_id': boundary_after_invocation_id,
641-
'events_before_rewind': len(events_before),
642-
'events_after_rewind': len(events_after),
643-
'history_before_hash': history_before_hash,
644-
'history_after_hash': history_after_hash,
639+
'rewind_before_invocation_id': rewind_before_invocation_id,
640+
'boundary_after_invocation_id': boundary_after_invocation_id,
641+
'events_before_rewind': len(events_before),
642+
'events_after_rewind': len(events_after),
643+
'history_before_hash': history_before_hash,
644+
'history_after_hash': history_after_hash,
645645
}
646646
receipt_hash = self._hash_rewind_payload(receipt_payload)
647647

@@ -659,18 +659,16 @@ def _hash_rewind_events(self, events: List[Event]) -> str:
659659
"""Hashes event summaries for deterministic rewind audit receipts."""
660660
summarized_events = []
661661
for event in events:
662-
summarized_events.append(
663-
{
664-
'event_id': event.id,
665-
'invocation_id': event.invocation_id,
666-
'author': event.author,
667-
'state_delta': event.actions.state_delta,
668-
'artifact_delta': event.actions.artifact_delta,
669-
'rewind_before_invocation_id': (
670-
event.actions.rewind_before_invocation_id
671-
),
672-
}
673-
)
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+
})
674672
return self._hash_rewind_payload({'events': summarized_events})
675673

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

tests/unittests/runners/test_runner_rewind.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ async def test_rewind_receipt_hash_is_deterministic(self):
287287
rewind_before_invocation_id="invocation2",
288288
)
289289

290-
assert first_receipt.history_before_hash == second_receipt.history_before_hash
290+
assert (
291+
first_receipt.history_before_hash == second_receipt.history_before_hash
292+
)
291293
assert first_receipt.history_after_hash == second_receipt.history_after_hash
292294
assert first_receipt.receipt_hash == second_receipt.receipt_hash

0 commit comments

Comments
 (0)