Repository navigation
feat: switch outer transcript/advice/handoff tags to opening-only pseudo-XML headers - #13
Conversation
…udo-XML headers Drop closing tags and XML text escaping for <primary-context>, <primary-transcript>, <advisor-advice>, and <advisor-handoff>. Body extends to message boundary; nested <primary-context kind="..."> sections in markdown body retain their existing escaping and closing tags. - Rename <instructions> to <user-instructions> in advisor-handoff - Remove escapeXmlText from all call sites except nested plan-mode - Update protocol docs (primary-transcript, ask-context, advice-delivery, overlay, prd) to reflect opening-only format - Update advisor system prompt to describe new format - Sync E2E steps, faux provider, TUI checks, and visual fixtures to verify literal tag fidelity in body instead of closing tag structure
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e84bd014f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ${latest.request} | ||
| <second-opinion> | ||
| ${latest.answer} | ||
| <user-instructions> |
There was a problem hiding this comment.
Escape reserved headers inside handoff sections
When the original request or Second Opinion contains a line such as <second-opinion> or <user-instructions>—for example, while reviewing this protocol—the raw interpolation creates an indistinguishable section delimiter, so the Primary Agent can treat subsequent request or Advisor text as a different section or as user instructions. Message boundaries cannot disambiguate these inner sections because the entire handoff is one user message; escape reserved header lines or deliver the sections with separate message boundaries.
Useful? React with 👍 / 👎.
Summary
将
<primary-context>、<primary-transcript>、<advisor-advice>、<advisor-handoff>改为 opening-only pseudo-XML metadata header。Body 不做 XML text escaping,范围由 message boundary 提供。Motivation
LLM 训练数据中大量使用裸 tag 作为分隔符,不做严格 XML 转义。对 LLM 来说,
<比<更难读——而 Advisor 是一个 LLM,需要阅读代码 diff、HTML、泛型等包含<>&的正文。详见
docs/engineering/primary-transcript.md新增的「外层格式:Opening-only Pseudo-XML Metadata Header」章节。Changes
外层 tag(opening-only,无 closing tag,无 escaping)
<primary-context>— Ask Context 的 hidden custom message body<primary-transcript>— pull_transcript tool result body<advisor-advice>— Advice 送达 Primary Agent 的 custom message body<advisor-handoff>— Handoff user message body,内部<instructions>改名为<user-instructions>未变更
<primary-context kind="plan-mode-reference">— 嵌套在 markdown body 内部,保留 closing tag + escaping<primary-head />— 保持单行 self-closingRuntime
delivery.ts— 删除 escaping function + closing tagsession.ts— Ask Context 和 handoff 删除 closing tags + escapingprimary-transcript.ts— Pull Transcript 删除 closing tag + escapingsession-history-format.ts— escapeXmlText 仅保留给嵌套 plan-mode sectionDocs
primary-transcript.md— 新增 opening-only 格式章节ask-context.md,advice-delivery.md,overlay.md,prd.md— 同步更新Tests