Skip to content

Write Tool includes metadata in output and created filecontent #5362

Closed

Description

@rwese

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 11, 2025
  2. tajbaba999 commented on Dec 11, 2025

    @tajbaba999

    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

  3. rwese commented on Dec 11, 2025

    @rwese
    ContributorAuthor

    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.

  4. tajbaba999 commented on Dec 11, 2025

    @tajbaba999

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

  5. self-assigned this
    on Dec 12, 2025
  6. rekram1-node commented on Dec 12, 2025

    @rekram1-node
    Contributor

    can someone share the session they replicate this in?

    opencode export > session.json

  7. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 12, 2025
  8. rwese commented on Dec 12, 2025

    @rwese
    ContributorAuthor

    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

  9. rwese commented on Dec 14, 2025

    @rwese
    ContributorAuthor

    one shorter example of the recent

    opencode --version
    
    1.0.152
    

    write_tool_output_with_metadata.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions