Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/google/adk/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,31 @@ async def _compute_artifact_delta_for_rewind(
)
else:
# Artifact version changed after rewind point. Restore to version at
# rewind point.
artifact_uri = artifact_util.get_artifact_uri(
# rewind point by loading the actual bytes (inline_data) rather than
# constructing a file_data reference, since GcsArtifactService and
# FileArtifactService do not support saving file_data parts.
loaded = await self.artifact_service.load_artifact(
app_name=self.app_name,
user_id=session.user_id,
session_id=session.id,
filename=filename,
version=vt,
)
artifact = types.Part(file_data=types.FileData(file_uri=artifact_uri))
if loaded and loaded.inline_data:
artifact = loaded
else:
# Fallback: artifact couldn't be loaded, mark as empty.
logger.warning(
'Could not load artifact %s version %s for rewind;'
' replacing with empty blob.',
filename,
vt,
)
artifact = types.Part(
inline_data=types.Blob(
mime_type='application/octet-stream', data=b''
)
)
Comment on lines +770 to +781
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: it might be worth logging a warning when the fallback is hit. A silent empty-blob replacement could be hard to debug if artifact storage is inconsistent

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, added a logger.warning with the filename and version so it is easy to trace. Both suggestions addressed in the latest push.

await self.artifact_service.save_artifact(
app_name=self.app_name,
user_id=session.user_id,
Expand Down
Loading