Write Tool includes metadata in output and created filecontent #3465

Open
opened 2026-02-16 17:40:12 -05:00 by yindo · 6 comments
Owner

Originally created by @rwese on GitHub (Dec 11, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Sometimes the write tools includes some of the metadata in its console & write output.

Happens when a completely new file is created.

-> Wrote .agent/Research/txt_record_quote_handling.md
...

somefile.yaml

- Go `%q` verb: Adds Go-style quoting</content>
<parameter name="filePath">.agent/Research/txt_record_quote_handling.md

already had a short discord chat with @rekram1-node.

OpenCode version

1.0.144

Steps to reproduce

Does not always happen.

Ask the AI Agent to produce a long and detailed report in a markdown style.

Screenshot and/or share link

Image

Operating System

macos 26, fedora 43 gnome

Terminal

ghostty

Originally created by @rwese on GitHub (Dec 11, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Sometimes the write tools includes some of the metadata in its console & **write** output. Happens when a completely new file is created. ``` -> Wrote .agent/Research/txt_record_quote_handling.md ... ``` `somefile.yaml` ```yaml - Go `%q` verb: Adds Go-style quoting</content> <parameter name="filePath">.agent/Research/txt_record_quote_handling.md ``` _already had a short discord chat with @rekram1-node_. ### OpenCode version 1.0.144 ### Steps to reproduce Does not always happen. Ask the AI Agent to produce a long and detailed report in a markdown style. ### Screenshot and/or share link <img width="1061" height="363" alt="Image" src="https://github.com/user-attachments/assets/6b1ff11c-7098-43dc-8645-41008d012adb" /> ### Operating System macos 26, fedora 43 gnome ### Terminal ghostty
yindo added the bug label 2026-02-16 17:40:12 -05:00
Author
Owner

@tajbaba999 commented on GitHub (Dec 11, 2025):

I think the issue happens because params.content sometimes contains metadata blocks. A very small fix is to sanitize the content before writing:

await Bun.write(filepath, typeof params.content === "string" ? params.content : "");

can i go ahead with this fix @rwese @rekram1-node

@tajbaba999 commented on GitHub (Dec 11, 2025): I think the issue happens because params.content sometimes contains metadata blocks. A very small fix is to sanitize the content before writing: `await Bun.write(filepath, typeof params.content === "string" ? params.content : "");` can i go ahead with this fix @rwese @rekram1-node
Author
Owner

@rwese commented on GitHub (Dec 11, 2025):

I am uncertain, this would be a band-aid, but the cause is that the write-tool is receiving this wrongly. 🤷

But it is pretty annoying, i run into this couple of times a day.

@rwese commented on GitHub (Dec 11, 2025): I am uncertain, this would be a band-aid, but the cause is that the write-tool is receiving this wrongly. 🤷 But it is pretty annoying, i run into this couple of times a day.
Author
Owner

@tajbaba999 commented on GitHub (Dec 11, 2025):

What is the correct/long-term fix instead of the band-aid workaround?

@tajbaba999 commented on GitHub (Dec 11, 2025): What is the correct/long-term fix instead of the band-aid workaround?
Author
Owner

@rekram1-node commented on GitHub (Dec 11, 2025):

can someone share the session they replicate this in?

opencode export > session.json

@rekram1-node commented on GitHub (Dec 11, 2025): can someone share the session they replicate this in? opencode export > session.json
Author
Owner

@rwese commented on GitHub (Dec 12, 2025):

Here are found session exports, to find the offending tool calls using ripgrep rg '\/content>\\n<par', pattern works for vim too.
i created a script to help me parse through my sessions:

uv run https://raw.githubusercontent.com/rwese/opencode_session_analyzer/main/oc_session_analyzer.py --export

here are the found results.

tool_write_artifacts.tgz

@rwese commented on GitHub (Dec 12, 2025): Here are found session exports, to find the offending tool calls using ripgrep `rg '\/content>\\n<par'`, pattern works for vim too. i created a script to help me parse through my sessions: `uv run https://raw.githubusercontent.com/rwese/opencode_session_analyzer/main/oc_session_analyzer.py --export` here are the found results. [tool_write_artifacts.tgz](https://github.com/user-attachments/files/24121350/tool_write_artifacts.tgz)
Author
Owner

@rwese commented on GitHub (Dec 14, 2025):

one shorter example of the recent

opencode --version

1.0.152

write_tool_output_with_metadata.json

@rwese commented on GitHub (Dec 14, 2025): one shorter example of the recent ``` opencode --version 1.0.152 ``` [write_tool_output_with_metadata.json](https://github.com/user-attachments/files/24149560/write_tool_output_with_metadata.json)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3465