Skip to main content

Overview

Artifacts is a structured tool return format used to render rich content (HTML, code, charts, etc.) in the Trajectory area instead of displaying raw text.

Background

Current tool return results have the following issues:
  1. Inconsistent formats: Different tools return different formats
  2. Difficult frontend parsing: Relies on regex to detect content types
  3. Limited rendering: Cannot distinguish renderable content from plain text
  4. Poor extensibility: Every new type requires modifying frontend detection logic

Data Structure Design

ToolResultContent

Structured representation of tool return content with the following fields:
FieldTypeDescription
typestringContent type (see table below)
datastringContent data
languagestring (optional)Programming language identifier
titlestring (optional)Title
metaobject (optional)Additional metadata

ToolResult

Standard tool return format:
FieldTypeDescription
successbooleanWhether successful
messagestringResult message
contentToolResultContent (optional)Structured content
file_pathstring (optional)Associated file path

Content Types

typeDescriptionRendering Method
textPlain text<pre> or <p>
htmlHTML content<iframe> sandbox rendering
markdownMarkdownMarkdown renderer
codeCodeSyntax-highlighted CodeBlock
jsonJSON dataJSON Viewer
imageImage<img>
errorError messageRed error styling

Frontend Rendering

The frontend selects the corresponding rendering component based on the content.type field: HTML content uses sandbox iframe preview, Markdown uses a renderer, code uses syntax highlighting, JSON uses a tree viewer, images are displayed directly, and errors use red styling.

Backward Compatibility

  • The frontend supports both new and old formats
  • Old format (plain text) is wrapped as content with type: "text"
  • Progressive migration without affecting existing functionality