Skip to content

refactor: replace hash tag format with ACP namespaced XML attributes#18

Merged
tuanhung303 merged 4 commits intomasterfrom
refactor/acp-hash-format
Feb 7, 2026
Merged

refactor: replace hash tag format with ACP namespaced XML attributes#18
tuanhung303 merged 4 commits intomasterfrom
refactor/acp-hash-format

Conversation

@tuanhung303
Copy link
Owner

Summary

  • Replaces old <type_hash>xxx</type_hash> trailing format with ACP namespaced XML attribute format (<acp:type prunable_hash="xxx">content</acp:type>) to prevent hash tags from leaking into user-visible text
  • Adds plain attribute support for segment tags (<file prunable_hash="xxx">content</file>) — injects prunable_hash directly onto existing XML tags instead of creating separate hash tags
  • All 557 tests passing, 0 failures

New Format

Context Format
Tool output <acp:tool prunable_hash="abc123">output...</acp:tool>
Assistant text <acp:message prunable_hash="def456">text...</acp:message>
Reasoning ref <acp:reasoning prunable_hash="fed987"/>
Message ref <acp:message prunable_hash="def456"/>
Segment <file prunable_hash="aaa111">content</file>

Why

When assistant responses had no tool calls, hash tags (<reasoning_hash>xxx</reasoning_hash>) fell back to text parts and were visible to the user. The new format wraps content with namespaced tags that the strip pipeline can cleanly unwrap (preserving inner content) rather than just deleting trailing tags.

Files Changed

  • lib/state/hash-registry.ts — New regexes (ACP_WRAP_REGEX, ACP_REF_REGEX, ATTR_HASH_REGEX, ALL_HASH_REGEX), rewritten strip/extract functions
  • lib/messages/prune.tswrapWithHash + createHashRef helpers, updated all injection/stripping/segment logic
  • lib/prompts/context-spec.ts — System prompt examples updated
  • lib/messages/todo-reminder.ts — Hash format reference updated
  • lib/strategies/context.ts — No functional change (already uses registry functions)
  • tests/messages/prune.test.ts — All assertions updated
  • tests/e2e/thinking-blocks.test.ts — All pipeline assertions updated

@tuanhung303 tuanhung303 merged commit 7146901 into master Feb 7, 2026
3 checks passed
@tuanhung303 tuanhung303 deleted the refactor/acp-hash-format branch February 9, 2026 23:37
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