Skip to content

fix(agent): escape Harmony compaction markers#5190

Merged
can1357 merged 1 commit into
mainfrom
farm/d665db31/sanitize-harmony-compaction
Jul 14, 2026
Merged

fix(agent): escape Harmony compaction markers#5190
can1357 merged 1 commit into
mainfrom
farm/d665db31/sanitize-harmony-compaction

Conversation

@roboomp

@roboomp roboomp commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Repro

Copilot-backed gpt-5.6-* Responses models reject payload text containing the Harmony analysis marker <|channel|>analysis. On the OMP side, bun test packages/ai/test/transcript-render.test.ts -t harmony confirms the Harmony transcript renderer intentionally emits <|start|>assistant<|channel|>analysis<|message|>...<|end|>, matching the marker in the reporter's minimized rejection payload.

Cause

packages/agent/src/compaction/compaction.ts and packages/agent/src/compaction/branch-summarization.ts used serializeConversation(..., preferredDialect(model.id)) directly when building plain summarization prompt text. For OpenAI-family model ids, packages/catalog/src/identity/dialect.ts selects the Harmony dialect, so assistant thinking became raw Harmony control-token text inside <conversation>...</conversation> and could be rejected before the summarizer ran.

Fix

  • Added serializeConversationForSummary in packages/agent/src/compaction/utils.ts to preserve native transcript readability while escaping Harmony control tokens for plain summary input.
  • Switched compaction summary, short-summary, turn-prefix, and branch-summary prompt construction to the summary-safe serializer.
  • Added regression coverage proving summary-bound Harmony serialization omits raw <|channel|>analysis while native Harmony transcript rendering remains unchanged.
  • Added an Unreleased changelog entry for packages/agent.

Verification

bun test packages/agent/test/serialize-conversation.test.ts packages/agent/test/remote-compaction.test.ts passed: 30 tests, 148 expectations. gh_push_branch completed the pre-publish gate and pushed farm/d665db31/sanitize-harmony-compaction at 9831386deba2. Fixes #5184

Escaped Harmony control-token markers when compaction serializes transcripts into plain summary prompts so Copilot gpt-5.6 models do not reject analysis-channel text.

Added regression coverage for summary-bound Harmony serialization while keeping native transcript rendering unchanged.

Fixes #5184
@cuipengfei

Copy link
Copy Markdown

@can1357 can1357 merged commit 3239b4e into main Jul 14, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot gpt-5.6-* rejects compaction payloads containing Harmony analysis marker

3 participants