Skip to content

Text artifact preview renders garbled characters for non-ASCII (multibyte) content #452

@Ishihara-exture

Description

@Ishihara-exture

🔴 Required Information

Describe the Bug:
When a tool saves a text artifact containing non-ASCII characters using
Part.from_text(), the preview in the Artifacts tab and inline chat bubble
renders garbled characters instead of the original text.

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:

  1. Create an agent with a tool that saves a text artifact:
async def save_text_file(filename: str, tool_context: ToolContext) -> str:
    part = types.Part.from_text(text="こんにちは")
    await tool_context.save_artifact("hello.txt", part)
    return "Saved"
  1. Run adk web and ask the agent to call the tool
  2. Open the Artifacts tab in the right panel
  3. Observe the text preview
    Expected Behavior:
こんにちは

Observed Behavior:

ã?"ã‚"ã?«ã?¡ã?¯

UTF-8 bytes are misinterpreted as Latin-1 (ISO-8859-1).

Environment Details:

  • ADK Library Version: 2.1.0
  • Desktop OS: Windows
  • Python Version: 3.12.10

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-2.5-flash

🟡 Optional Information

Regression:
N/A

Logs:
N/A

Screenshots / Video:
Before (garbled):
Image
After applying fix (decodeURIComponent(escape(atob(base64))))
Image

Additional Context:
Root Cause:
renderArtifact() encodes text as btoa(unescape(encodeURIComponent(text))),
but getTextContent() only calls atob(base64) without the reverse step.

Fix (2 occurrences in artifact-tab.component.ts):

Before:

return atob(base64);

After:

return decodeURIComponent(escape(atob(base64)));

Minimal Reproduction Code:

async def save_text_file(filename: str, tool_context: ToolContext) -> str:
    part = types.Part.from_text(text="こんにちは")
    await tool_context.save_artifact("hello.txt", part)
    return "Saved"

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions