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
import asyncio
import tempfile
from google.adk.artifacts import FileArtifactService, InMemoryArtifactService
from google.genai import types
async def main() -> None:
for label, svc in [
("in-memory", InMemoryArtifactService()),
("file", FileArtifactService(base_path=tempfile.mkdtemp())),
]:
await svc.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 = await svc.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
Description
When you save an artifact whose
Part.inline_data.display_nameis set (e.g., auser-facing filename), the value is lost on
load_artifactforFileArtifactServiceandGcsArtifactService.InMemoryArtifactServicepreserves it. Same shape as #3157 (
.textlost on load), fixed by #5155 forthe text path.
Downstream, the genai → A2A converter at
part_converter.py:218reads
name=part.inline_data.display_name, soFilePart.file.namebecomesNoneand clients fall back to a genericattachment.<ext>label.To Reproduce
Output:
Expected
display_nameround-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_nameis also not written tometadata.jsonon save, so it'sgenuinely lost on disk.
GcsArtifactService._load_artifact(line 271)
uses
Part.from_bytes(...), which setsdisplay_name=None.Environment
google-adk==2.1.0Question
Is this expected behavior, or a bug?
Related
.textnot preserved on load. Same shape.display_namefix would livein the same place.