How to render HTML in agentspace(Gemini Enterprise) integrated with agent engine #4404
Replies: 2 comments
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Yes, HTML artifacts are rendered in the Agentspace chat. You can save your interactive chart as an HTML file and it will be displayed. Hello! As of version 1.2.0, ADK supports rendering HTML artifacts directly in the chat window [1]. You can use the Here is an example of how you could save an HTML artifact: from adk.api import save_artifact
chart_html = """
<!DOCTYPE html>
<html>
<head>
<title>My Interactive Chart</title>
</head>
<body>
<h1>My Chart</h1>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
cxt.moveTo(0,0);
cxt.lineTo(200,100);
cxt.stroke();
</script>
</body>
</html>
"""
save_artifact(
"interactive_chart.html",
chart_html.encode("utf-8"),
mime_type="text/html",
description="An interactive chart generated by the agent.",
)This will save the HTML file as an artifact, and the Agentspace UI will render it in the chat. Let me know if you have any other questions! [1] https://github.com/google/adk-python/blob/main/CHANGELOG.md |
Beta Was this translation helpful? Give feedback.
-
|
I implemented HTML artifact saving with Here's how we're saving the artifact: import vl_convert as vlc
from google.genai.types import Part
# Generate self-contained HTML with all JS inlined (no CDN dependencies)
html = vlc.vegalite_to_html(vega_lite_spec, config=theme_config, bundle=True)
# Save as artifact via ADK ToolContext
body_part = Part.from_bytes(data=html.encode("utf-8"), mime_type="text/html")
await tool_context.save_artifact(filename="chart.html", artifact=body_part)The generated HTML works correctly when opened directly in a browser: vegaEmbed renders an interactive chart with Could you clarify whether text/html artifact rendering is actually supported in Gemini Enterprise, and if so, what Below is a screenshot of the error message shown by Gemini Enterprise:
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
If an agent saves an HTML artifact, will it be rendered in the Agentspace chat?
I’m asking because I plan to build an interactive chart, and my approach is to use HTML with Canvas.
Beta Was this translation helpful? Give feedback.
All reactions