Skip to content

[Web UI] Support text-based artifacts preview (not just inlineData/binary) #4196

@StevenZhang233

Description

@StevenZhang233

Is your feature request related to a problem? Please describe.

When using types.Part.from_text() to create text-based artifacts (like source code files), the ADK Web UI fails to display them with error "Failed to fetch artifact data".

The backend API returns the data correctly, but the frontend only handles inlineData format, not text format.

Describe the solution you'd like

The Web UI should support previewing text-based artifacts created with Part.from_text(). The frontend renderArtifact function should handle both:

  • {"inlineData": {"mimeType": "...", "data": "..."}} (current)
  • {"text": "..."} (not supported)

For text artifacts, display them as plain text or with syntax highlighting for code files.

Describe alternatives you've considered

  1. Convert text to base64 and use Part.from_bytes() with inlineData - but this adds unnecessary complexity for text content
  2. Ignore the UI error and only use API directly - works but poor UX

Additional context

Reproduction steps:

artifact = types.Part.from_text(text="print('hello')")
await tool_context.save_artifact(filename="main.py", artifact=artifact)

API response works fine:

curl "http://localhost:8000/.../artifacts/main.py"
# Returns: {"text": "print('hello')"}

Environment:
google-adk version: 1.22.1
Python: 3.13
OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    web[Component] This issue will be transferred to adk-web

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions