refactor: replace hash tag format with ACP namespaced XML attributes#18
Merged
tuanhung303 merged 4 commits intomasterfrom Feb 7, 2026
Merged
refactor: replace hash tag format with ACP namespaced XML attributes#18tuanhung303 merged 4 commits intomasterfrom
tuanhung303 merged 4 commits intomasterfrom
Conversation
…to prevent UI leakage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<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<file prunable_hash="xxx">content</file>) — injectsprunable_hashdirectly onto existing XML tags instead of creating separate hash tagsNew Format
<acp:tool prunable_hash="abc123">output...</acp:tool><acp:message prunable_hash="def456">text...</acp:message><acp:reasoning prunable_hash="fed987"/><acp:message prunable_hash="def456"/><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 functionslib/messages/prune.ts—wrapWithHash+createHashRefhelpers, updated all injection/stripping/segment logiclib/prompts/context-spec.ts— System prompt examples updatedlib/messages/todo-reminder.ts— Hash format reference updatedlib/strategies/context.ts— No functional change (already uses registry functions)tests/messages/prune.test.ts— All assertions updatedtests/e2e/thinking-blocks.test.ts— All pipeline assertions updated