Skip to content

feat: switch outer transcript/advice/handoff tags to opening-only pseudo-XML headers - #13

Merged
kkkiio merged 1 commit into
mainfrom
feat/opening-only-pseudo-xml-protocol
Jul 30, 2026
Merged

kkkiio merged 1 commit into
mainfrom
feat/opening-only-pseudo-xml-protocol

Conversation

@kkkiio

@kkkiio kkkiio commented Jul 28, 2026

Copy link
Copy Markdown
Owner

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 来说,&lt; 比 < 更难读——而 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-closing

Runtime

  • delivery.ts — 删除 escaping function + closing tag
  • session.ts — Ask Context 和 handoff 删除 closing tags + escaping
  • primary-transcript.ts — Pull Transcript 删除 closing tag + escaping
  • session-history-format.ts — escapeXmlText 仅保留给嵌套 plan-mode section

Docs

  • primary-transcript.md — 新增 opening-only 格式章节
  • ask-context.md, advice-delivery.md, overlay.md, prd.md — 同步更新

Tests

  • E2E steps / faux provider / TUI checks / visual fixtures — 验证 literal tag 在 body 中保真,不验证 closing tag 结构
  • Unit test 同步更新

…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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +334 to +337
${latest.request}
<second-opinion>
${latest.answer}
<user-instructions>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@kkkiio
kkkiio merged commit 7475a11 into main Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant