Agent Render Linking
Create browser links for artifacts rendered by agent-render.com.
Project context
Agent Render is:
- - open source
- publicly hosted on Cloudflare Pages at INLINECODE1
- self-hostable for people who want their own deployment
- meant to provide a zero-retention browser viewer for agent-shared artifacts
Source repository:
Core rule
Keep the artifact content in the URL fragment, not in normal query params.
Use this fragment shape:
CODEBLOCK0
Supported codecs:
- -
plain: base64url-encoded JSON envelope - INLINECODE4 :
lz-string compressed JSON encoded for URL-safe transport - INLINECODE6 : deflate-compressed UTF-8 JSON bytes encoded as base64url
- INLINECODE7 : domain-dictionary substitution + brotli (quality 11) + base76/base1k/baseBMP encoding (~70% smaller than deflate with baseBMP). Fetch the shared dictionary from
https://agent-render.com/arx-dictionary.json to apply substitutions locally before brotli compression. Three encoding tiers: baseBMP (~62k safe BMP code points, ~15.92 bits/char, best density), base1k (1774 Unicode code points U+00A1–U+07FF), and base76 (ASCII fallback). The encoder tries all three and picks the shortest. - packed wire mode (
p: 1) may be used automatically to shorten transport keys
Prefer:
- 1. shortest valid fragment for the target surface
- codec priority
arx -> deflate -> lz -> plain unless explicitly overridden - packed wire mode when available
Envelope shape
Use this JSON envelope:
CODEBLOCK1
Supported artifact kinds
Markdown
CODEBLOCK2
Code
CODEBLOCK3
Diff
Prefer a real unified git patch in patch.
CODEBLOCK4
Use view: "unified" or view: "split".
A single patch string may contain multiple diff --git sections.
CSV
CODEBLOCK5
JSON
CODEBLOCK6
Multi-artifact bundles
Use multiple artifacts when the user should switch between related views.
Example cases:
- - summary markdown + patch diff
- report markdown + raw CSV
- config JSON + related code file
Set activeArtifactId to the artifact that should open first.
Link construction
Construct the final URL as:
CODEBLOCK7
For plain:
- 1. Serialize the envelope as compact JSON
- Base64url-encode it
- Append it after INLINECODE18
For lz:
- 1. Serialize the envelope as compact JSON
- Compress with
lz-string URL-safe encoding - Append it after INLINECODE21
For deflate:
- 1. Serialize the envelope as compact JSON (or packed wire form)
- Encode JSON to UTF-8 bytes
- Deflate the bytes
- Base64url-encode the compressed bytes
- Append it after INLINECODE23
Shared arx dictionary
The arx codec uses a substitution dictionary to replace common patterns with short byte sequences before brotli compression. The dictionary is served as a static JSON file:
- - Endpoint: INLINECODE25
- Pre-compressed:
https://agent-render.com/arx-dictionary.json.br (brotli, ~929 bytes)
The dictionary contains two arrays:
- -
singleByteSlots: up to 25 patterns mapped to single control bytes (highest compression value) - INLINECODE28 : additional patterns mapped to two-byte sequences (0x00 prefix + index)
To use the dictionary for local arx encoding:
- 1. Fetch INLINECODE30
- Apply substitutions in order: for each entry, replace all occurrences of the pattern in the serialized JSON envelope with its corresponding control byte(s)
- Brotli-compress the substituted bytes at quality 11
- Encode the compressed bytes using baseBMP (preferred, smallest), base1k (mid-tier), or base76 (ASCII fallback)
- BaseBMP uses ~62k safe BMP code points (U+00A1–U+FFEF, skipping surrogates, combining marks, zero-width chars). Prefix the encoded string with U+FFF0 marker. ~15.92 bits/char
- Base1k uses 1774 Unicode code points (U+00A1–U+07FF, skipping combining diacriticals and soft hyphen). ~10.79 bits/char
- Base76 uses 77 ASCII fragment-safe characters — use this if the target surface cannot handle Unicode in URL fragments. ~6.27 bits/char
- Try all three and pick the shortest
- 5. Prepend
v1.arx.<dictVersion>. to form the fragment payload (use the same dictionary version used for substitution)
The dictionary includes JSON envelope boilerplate patterns (like ","kind":"Markdown","content":"), JSON-escaped Markdown syntax, programming keywords, and common English words. The viewer loads the same dictionary on startup to reverse substitutions during decode.
If the dictionary fetch fails, fall back to deflate codec.
Practical limits
Respect these limits:
- - target fragment budget: about 8,000 characters
- target decoded payload budget: about 200,000 characters
- strict Discord practical budget for linked text workflows: about 1,500 characters
If a link is getting too large:
- 1. try
arx first, then deflate, then lz, then INLINECODE37 - allow packed wire mode
- trim unnecessary prose or metadata
- prefer a focused artifact over a bloated one
- return a structured failure when the payload cannot fit the requested budget
Agent budget mode
When the caller provides a strict budget (for example 1,500 chars):
- 1. encode using all available candidates (
arx/deflate/lz/plain, packed and non-packed) - choose the shortest fragment that is within budget
- if no candidate fits, return the shortest fragment plus a clear budget failure explanation
Do not silently truncate content to force fit.
Formatting links in chat
Use platform-specific link text only on surfaces that support it cleanly.
Discord
Prefer standard Markdown links:
CODEBLOCK8
Examples:
- - INLINECODE39
- INLINECODE40
- INLINECODE41
Telegram
Prefer HTML links because OpenClaw Telegram outbound text uses parse_mode: "HTML".
CODEBLOCK9
Slack
Prefer Slack mrkdwn link syntax:
CODEBLOCK10
All other OpenClaw chat surfaces
For WhatsApp, Signal, iMessage, Google Chat, IRC, LINE, and any other surface without reliable inline link-text formatting, do not force Markdown-style links.
Use:
- - a short summary line first
- then the raw URL on its own line
If a provider later exposes a reliable native linked-text format, use that provider-specific syntax instead of generic Markdown.
Output style
When sharing a link:
- - keep the summary short
- make the artifact title human-readable
- use filenames when they help the viewer
- do not narrate the transport details unless the user asks
Good defaults
- - Prefer one strong artifact over many weak ones
- Prefer
patch for diffs - Prefer readable titles
- Prefer Markdown link text when supported
- Prefer shortest-by-measurement instead of human guesses
- Use budget-aware encoding for Discord-like constraints
Avoid
- - Do not put raw artifact content in normal query params
- Do not upload artifact content to a server for this workflow
- Do not dump giant noisy bundles when a focused artifact is enough
- Do not invent unsupported fields unless the renderer has added them
- Do not handcraft packed envelopes manually if helper utilities are available; construct logical envelopes and let transport logic pack automatically
Agent Render 链接生成
为 agent-render.com 渲染的制品创建浏览器链接。
项目背景
Agent Render 具有以下特性:
- - 开源
- 在 Cloudflare Pages 上公开托管于 agent-render.com
- 支持自托管,方便用户自行部署
- 旨在为智能体共享的制品提供零保留的浏览器查看器
源代码仓库:
- - https://github.com/baanish/agent-render
核心规则
将制品内容保留在 URL 片段中,而非普通查询参数中。
使用以下片段格式:
text
#agent-render=v1.<编解码器>.<负载> (plain | lz | deflate)
#agent-render=v1.arx.<字典版本>.<负载> (arx)
支持的编解码器:
- - plain:base64url 编码的 JSON 信封
- lz:经 lz-string 压缩并编码为 URL 安全传输格式的 JSON
- deflate:经 deflate 压缩的 UTF-8 JSON 字节,编码为 base64url 格式
- arx:领域字典替换 + brotli(质量等级 11)+ base76/base1k/baseBMP 编码(使用 baseBMP 时比 deflate 小约 70%)。从 https://agent-render.com/arx-dictionary.json 获取共享字典,在 brotli 压缩前本地执行替换。三种编码层级:baseBMP(约 62k 安全 BMP 码点,约 15.92 比特/字符,密度最高)、base1k(1774 个 Unicode 码点 U+00A1–U+07FF)和 base76(ASCII 回退)。编码器会尝试所有三种方式并选择最短结果。
- 打包传输模式(p: 1)可自动启用以缩短传输键
优先选择:
- 1. 目标平台的最短有效片段
- 编解码器优先级 arx -> deflate -> lz -> plain,除非明确覆盖
- 可用时启用打包传输模式
信封格式
使用以下 JSON 信封:
json
{
v: 1,
codec: plain,
title: 制品包标题,
activeArtifactId: artifact-1,
artifacts: [
{
id: artifact-1,
kind: markdown,
title: 周报,
filename: weekly-report.md,
content: # 报告
}
]
}
支持的制品类型
Markdown
json
{
id: report,
kind: markdown,
title: 周报,
filename: weekly-report.md,
content: # 报告\n\n- 项目一
}
代码
json
{
id: code,
kind: code,
title: viewer-shell.tsx,
filename: viewer-shell.tsx,
language: tsx,
content: export function ViewerShell() {\n return ;\n}
}
差异对比
优先在 patch 中使用真实的统一 git 补丁。
json
{
id: patch,
kind: diff,
title: viewer-shell.tsx 差异,
filename: viewer-shell.patch,
patch: diff --git a/viewer-shell.tsx b/viewer-shell.tsx\n--- a/viewer-shell.tsx\n+++ b/viewer-shell.tsx\n@@ -1 +1 @@\n-旧内容\n+新内容\n,
view: split
}
使用 view: unified 或 view: split。
单个 patch 字符串可包含多个 diff --git 段落。
CSV
json
{
id: metrics,
kind: csv,
title: 指标快照,
filename: metrics.csv,
content: name,value\nrequests,42
}
JSON
json
{
id: manifest,
kind: json,
title: 清单,
filename: manifest.json,
content: {\n \ready\: true\n}
}
多制品包
当用户需要在相关视图间切换时,使用多个制品。
示例场景:
- - 摘要 markdown + 补丁差异
- 报告 markdown + 原始 CSV
- 配置 JSON + 相关代码文件
将 activeArtifactId 设置为应首先打开的制品。
链接构建
构建最终 URL 的格式为:
text
https://agent-render.com/#agent-render=v1.<编解码器>.<负载> (plain | lz | deflate)
https://agent-render.com/#agent-render=v1.arx.<字典版本>.<负载> (arx)
对于 plain:
- 1. 将信封序列化为紧凑 JSON
- 进行 Base64url 编码
- 追加到 v1.plain. 之后
对于 lz:
- 1. 将信封序列化为紧凑 JSON
- 使用 lz-string URL 安全编码进行压缩
- 追加到 v1.lz. 之后
对于 deflate:
- 1. 将信封序列化为紧凑 JSON(或打包传输形式)
- 将 JSON 编码为 UTF-8 字节
- 对字节进行 deflate 压缩
- 对压缩后的字节进行 Base64url 编码
- 追加到 v1.deflate. 之后
共享 arx 字典
arx 编解码器使用替换字典,在 brotli 压缩前将常见模式替换为短字节序列。该字典以静态 JSON 文件形式提供:
- - 端点:https://agent-render.com/arx-dictionary.json
- 预压缩版本:https://agent-render.com/arx-dictionary.json.br(brotli 压缩,约 929 字节)
字典包含两个数组:
- - singleByteSlots:最多 25 个模式,映射到单个控制字节(压缩价值最高)
- extendedSlots:额外模式,映射到两字节序列(0x00 前缀 + 索引)
在本地进行 arx 编码时使用字典的步骤:
- 1. 获取 https://agent-render.com/arx-dictionary.json
- 按顺序执行替换:对于每个条目,将序列化 JSON 信封中所有匹配的模式替换为对应的控制字节
- 以质量等级 11 对替换后的字节进行 Brotli 压缩
- 使用 baseBMP(首选,最小)、base1k(中间层级)或 base76(ASCII 回退)对压缩后的字节进行编码
- BaseBMP 使用约 62k 安全 BMP 码点(U+00A1–U+FFEF,跳过代理项、组合标记、零宽字符)。编码字符串前添加 U+FFF0 标记。约 15.92 比特/字符
- Base1k 使用 1774 个 Unicode 码点(U+00A1–U+07FF,跳过组合变音符号和软连字符)。约 10.79 比特/字符
- Base76 使用 77 个 ASCII 片段安全字符——当目标平台无法处理 URL 片段中的 Unicode 时使用此方案。约 6.27 比特/字符
- 尝试所有三种方式并选择最短结果
- 5. 添加 v1.arx.<字典版本>. 前缀形成片段负载(使用与替换时相同的字典版本)
字典包含 JSON 信封样板模式(如 ,kind:Markdown,content:)、JSON 转义的 Markdown 语法、编程关键词和常见英语单词。查看器在启动时加载相同字典以在解码过程中反向替换。
如果字典获取失败,回退到 deflate 编解码器。
实际限制
请遵守以下限制:
- - 目标片段预算:约 8,000 个字符
- 目标解码负载预算:约 200,000 个字符
- Discord 链接文本工作流的严格实际预算:约 1,500 个字符
如果链接过大:
- 1. 首先尝试 arx,然后 deflate,接着 lz,最后 plain
- 允许打包传输模式
- 修剪不必要的散文或元数据
- 优先选择聚焦的制品而非臃肿的制品
- 当负载无法满足请求预算时,返回结构化失败信息
智能体预算模式
当调用方提供严格预算(例如 1,500 个字符)时:
- 1. 使用所有可用候选方案(arx/defl