Files
bot/docs/zh-CN/reference/transcript-hygiene.md
zeekay acaeda400a Eradicate OpenClaw — resolve merge conflicts and finish the rebrand
Three coordinated things:

1. Resolve the committed upstream/main merge conflicts. 94 files were
   sitting with raw <<<<<<< HEAD ... >>>>>>> upstream/main blocks. Every
   conflict had HanzoBot/Bot on HEAD and OpenClaw on upstream. Resolved
   by keeping HEAD everywhere — 540 conflict blocks.

2. Rewrite remaining OpenClaw text refs.
     OPENCLAW   → HANZO_BOT
     OpenClaw   → HanzoBot          (PascalCase type identifiers)
     openclaw   → bot               (codebase convention — botToken,
                                    botUsername etc.; avoids invalid
                                    hyphenated JS identifiers)
     openclaw[_]/openclaw[A-Z] → bot[_]/bot[A-Z]   (compound)
     ai.openclaw.x → ai.hanzo.bot.x  (JVM package path)

3. Delete or rename openclaw-named file paths (116 of them). Dead
   duplicates with a Bot-named canonical from the partial migration:
   deleted. Otherwise renamed.
     ai/openclaw/**           → deleted (ai/hanzo/bot/** canonical)
     Sources/OpenClaw*/       → deleted (Sources/Bot* canonical)
     Tests/OpenClawIPCTests/  → deleted (Tests/BotIPCTests canonical)
     OpenClawKit/             → deleted (BotKit canonical)
     openclaw-tools.*.ts      → deleted (bot-tools.*.ts canonical)
     openclaw-root.ts etc.    → deleted (bot-root.ts canonical)
     types.openclaw.ts        → deleted (types.bot.ts canonical)
     extensions/*/openclaw.plugin.json → renamed hanzo-bot.plugin.json
     docs/start/openclaw.md   → renamed hanzo-bot.md (+ zh-CN)
     docs/assets/openclaw-*.png, whatsapp-openclaw*.jpg → deleted
     scripts/.../openclaw-*   → deleted (bot/hanzo-bot parallels)
     openclaw.mjs             → deleted (hanzo-bot.mjs is package.bin)

Then patched 65 broken JS/TS import strings where hanzo-bot had ended
up inside an import path ('./types.hanzo-bot.js' → './types.bot.js'
etc., since the on-disk filename uses the brand-neutral bot- prefix).

Pre-existing lint debt cleaned up to get oxlint --type-aware to 0/0:
removed the dead i18n test that referenced a path no longer existing;
defined the missing DIDConfig and WalletConfig types in types.base.ts
(they were imported but never declared); dropped unused imports;
collapsed redundant type assertion and a tautological meta.bot lookup
that the openclaw→bot rename made redundant.

The a2ui.bundle.js generated artifact is kept at its pre-rebrand
contents — it gets regenerated by 'pnpm canvas:a2ui:bundle' from
sources I cannot rebuild in this commit; the source side is clean.

Verified: 0 occurrences of openclaw (case-insensitive) in tree source
content, 0 file or directory paths with openclaw in the name; oxlint
--type-aware src test reports 0/0.
2026-05-11 17:56:29 -07:00

3.8 KiB
Raw Permalink Blame History

read_when, summary, title, x-i18n
read_when summary title x-i18n
你正在调试与对话记录结构相关的提供商请求拒绝问题
你正在修改对话记录清理或工具调用修复逻辑
你正在调查跨提供商的工具调用 id 不匹配问题
参考:提供商特定的对话记录清理与修复规则 对话记录清理
generated_at model provider source_hash source_path workflow
2026-02-01T21:38:16Z claude-opus-4-5 pi 6ce62fad0b07c4d8575c9cdb1c8c2663695ef2d4221cf4a0964fce03461523af reference/transcript-hygiene.md 15

对话记录清理(提供商修正)

本文档描述了在运行前(构建模型上下文时)应用于对话记录的提供商特定修正。这些是内存中的调整,用于满足提供商的严格要求。它们不会重写磁盘上存储的 JSONL 对话记录。

涵盖范围包括:

  • 工具调用 id 清理
  • 工具结果配对修复
  • 轮次验证 / 排序
  • 思考签名清理
  • 图片负载清理

如需了解对话记录存储细节,请参阅:


运行位置

所有对话记录清理逻辑集中在嵌入式运行器中:

  • 策略选择:src/agents/transcript-policy.ts
  • 清理/修复应用:src/agents/pi-embedded-runner/google.ts 中的 sanitizeSessionHistory

策略根据 provider、modelApi 和 modelId 来决定应用哪些规则。


全局规则:图片清理

图片负载始终会被清理,以防止因大小限制导致提供商端拒绝(对超大 base64 图片进行缩放/重新压缩)。

实现:

  • src/agents/pi-embedded-helpers/images.ts 中的 sanitizeSessionMessagesImages
  • src/agents/tool-images.ts 中的 sanitizeContentBlocksImages

提供商矩阵(当前行为)

OpenAI / OpenAI Codex

  • 仅图片清理。
  • 切换到 OpenAI Responses/Codex 模型时,丢弃孤立的推理签名(没有后续内容块的独立推理项)。
  • 不进行工具调用 id 清理。
  • 不进行工具结果配对修复。
  • 不进行轮次验证或重新排序。
  • 不生成合成工具结果。
  • 不剥离思考签名。

Google (Generative AI / Gemini CLI / Antigravity)

  • 工具调用 id 清理:严格字母数字。
  • 工具结果配对修复和合成工具结果。
  • 轮次验证(Gemini 风格的轮次交替)。
  • Google 轮次排序修正(如果历史记录以助手开头,则在前面添加一个小型用户引导消息)。
  • Antigravity Claude:规范化思考签名;丢弃未签名的思考块。

Anthropic / Minimax(Anthropic 兼容)

  • 工具结果配对修复和合成工具结果。
  • 轮次验证(合并连续的用户轮次以满足严格交替要求)。

Mistral(包括基于 model-id 的检测)

  • 工具调用 id 清理:strict9(字母数字,长度 9)。

OpenRouter Gemini

  • 思考签名清理:剥离非 base64 的 thought_signature 值(保留 base64)。

其他所有提供商

  • 仅图片清理。

历史行为(2026.1.22 之前)

在 2026.1.22 版本发布之前,HanzoBot 应用了多层对话记录清理:

  • 一个对话记录清理扩展在每次上下文构建时运行,可以:
    • 修复工具使用/结果配对。
    • 清理工具调用 id(包括保留 _/- 的非严格模式)。
  • 运行器也执行提供商特定的清理,导致重复工作。
  • 在提供商策略之外还存在额外的变更,包括:
    • 在持久化之前从助手文本中剥离 <final> 标签。
    • 丢弃空的助手错误轮次。
    • 截断工具调用之后的助手内容。

这种复杂性导致了跨提供商的回归问题(尤其是 openai-responses 的 call_id|fc_id 配对)。2026.1.22 的清理移除了该扩展,将逻辑集中到运行器中,并使 OpenAI 在图片清理之外不做任何修改。