Skip to content

feat(artifacts): add save_media_frames() for batched media persistence - #7152

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/982888971
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/982888971

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Sep 17, 2026

Copy link
Copy Markdown

feat(artifacts): add save_media_frames() for batched media persistence

Introduces save_media_frames() on the artifact service layer. It accepts
frames: list[MediaFrame] -- a batch of media blobs each paired with its
capture timestamp -- and persists them as a single artifact, so a stream of
realtime video or image frames can be stored in one call instead of one
artifact per frame.

Implemented across the service hierarchy:

  • MediaFrame: new model pairing a types.Blob with its capture timestamp,
    exported from google.adk.artifacts.
  • BaseArtifactService.save_media_frames(): new non-abstract method that
    raises NotImplementedError by default, so existing third-party artifact
    services keep working without modification.
  • InMemoryArtifactService, FileArtifactService, GcsArtifactService:
    concrete implementations.
  • _ForwardingArtifactService and PerAgentFileArtifactService: delegate to
    the wrapped service.

This is a storage-layer change with no dependency on the live flow or the
cache manager, and it adds no new call sites; the caller that uses it ships
separately. It is not quite purely additive: GcsArtifactService's
delete_artifact() now has media frames to clean up, which it does from the
listing it already performs rather than by issuing an additional one.

Also documents the new method in the artifact service guide.

Testing:

  • tests/unittests/artifacts and
    tests/unittests/tools/test_forwarding_artifact_service.py: 999 passed.
  • New coverage: round-trip persistence and retrieval per backend, empty-frame
    handling, timestamp ordering, and NotImplementedError from the base class.

@copybara-service
copybara-service Bot force-pushed the copybara/982888971 branch 4 times, most recently from d2f1377 to 11a9efd Compare September 17, 2026 18:29
Introduces `save_media_frames()` on the artifact service layer. It accepts
`frames: list[MediaFrame]` -- a batch of media blobs each paired with its
capture timestamp -- and persists them as a single artifact, so a stream of
realtime video or image frames can be stored in one call instead of one
artifact per frame.

Implemented across the service hierarchy:

- `MediaFrame`: new model pairing a `types.Blob` with its capture timestamp,
  exported from `google.adk.artifacts`.
- `BaseArtifactService.save_media_frames()`: new non-abstract method that
  raises `NotImplementedError` by default, so existing third-party artifact
  services keep working without modification.
- `InMemoryArtifactService`, `FileArtifactService`, `GcsArtifactService`:
  concrete implementations.
- `_ForwardingArtifactService` and `PerAgentFileArtifactService`: delegate to
  the wrapped service.

This is a storage-layer change with no dependency on the live flow or the
cache manager, and it adds no new call sites; the caller that uses it ships
separately. It is not quite purely additive: `GcsArtifactService`'s
`delete_artifact()` now has media frames to clean up, which it does from the
listing it already performs rather than by issuing an additional one.

Also documents the new method in the artifact service guide.

Testing:
- `tests/unittests/artifacts` and
  `tests/unittests/tools/test_forwarding_artifact_service.py`: 999 passed.
- New coverage: round-trip persistence and retrieval per backend, empty-frame
  handling, timestamp ordering, and `NotImplementedError` from the base class.
PiperOrigin-RevId: 982888971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant