Skip to content

fix: strip tool history from Write content-generation context#777

Merged
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:fix/write-tool-content-gen-strip-tool-history
May 19, 2026
Merged

fix: strip tool history from Write content-generation context#777
bobleer merged 1 commit into
GCWing:mainfrom
bobleer:fix/write-tool-content-gen-strip-tool-history

Conversation

@bobleer
Copy link
Copy Markdown
Collaborator

@bobleer bobleer commented May 19, 2026

Problem

Weak models imitate tool-call XML format when the history passed to the
second-stage Write content-generation request contains tool_use/tool_result
messages. This causes raw XML to be written into the file instead of actual
file content, triggering a Delete -> Write cycle from the user's perspective.

Root cause

In generate_write_tool_contents, content_messages was built by directly
cloning the full ai_messages history, including all tool-call and tool-result
turns. Weak models see this format in context and reproduce it inside
<bitfun_contents> tags.

Fix

  • Drop role=tool messages from content_messages entirely
  • Replace assistant messages carrying tool_calls with a plain-text summary
    [called tools: ToolName] so no tool-call syntax appears in context
  • Add prompt rule 7 explicitly forbidding tool_call XML inside
    <bitfun_contents> tags

Verification

cargo check -p bitfun-core passes.

Weak models imitate tool-call XML format when the history passed to the
second-stage content-generation request contains tool_use/tool_result
messages, causing raw XML to be written into the file instead of actual
content.

- Drop role=tool messages from content_messages entirely
- Replace assistant messages that carry tool_calls with a plain-text
  summary [called tools: ToolName] so the model sees no tool-call syntax
- Add prompt rule 7 explicitly forbidding tool_call XML inside
  <bitfun_contents> tags
@bobleer bobleer merged commit 1ff2210 into GCWing:main May 19, 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