Skip to content

Blob.display_name not preserved when loading binary artifacts from FileArtifactService / GcsArtifactService #5833

Description

@eliasecchig

Description

When you save an artifact whose Part.inline_data.display_name is set (e.g., a
user-facing filename), the value is lost on load_artifact for
FileArtifactService and GcsArtifactService. InMemoryArtifactService
preserves it. Same shape as #3157 (.text lost on load), fixed by #5155 for
the text path.

Downstream, the genai → A2A converter at
part_converter.py:218
reads name=part.inline_data.display_name, so FilePart.file.name becomes
None and clients fall back to a generic attachment.<ext> label.

To Reproduce

importasyncioimporttempfilefromgoogle.adk.artifactsimportFileArtifactService, InMemoryArtifactServicefromgoogle.genaiimporttypesasyncdefmain() ->None:
forlabel, svcin [
("in-memory", InMemoryArtifactService()),
("file", FileArtifactService(base_path=tempfile.mkdtemp())),
]:
awaitsvc.save_artifact(
app_name="app", user_id="u", session_id="s", filename="report.png",
artifact=types.Part(
inline_data=types.Blob(
mime_type="image/png",
data=b"\x89PNG\r\n\x1a\n...",
display_name="report.png",
)
),
)
loaded=awaitsvc.load_artifact(
app_name="app", user_id="u", session_id="s", filename="report.png"
)
print(f"{label:10s} display_name={loaded.inline_data.display_name!r}")
asyncio.run(main())

Output:

in-memory display_name='report.png'
file display_name=None

Expected

display_name round-trips through save → load for all artifact services.

Observed

  • FileArtifactService._load_artifact
    (line 494)
    rebuilds the Part as
    types.Part(inline_data=types.Blob(mime_type=mime_type, data=data)).
    display_name is also not written to metadata.json on save, so it's
    genuinely lost on disk.
  • GcsArtifactService._load_artifact
    (line 271)
    uses Part.from_bytes(...), which sets display_name=None.

Environment

  • google-adk==2.1.0
  • Python 3.12.13, macOS (also reproduces on linux)

Question

Is this expected behavior, or a bug?

Related

Metadata

Metadata

Assignees

Labels

request clarification[Status] The maintainer need clarification or more information from the authorservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etcstale[Status] Issues which have been marked inactive since there is no user response

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions