You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: plugin hook for streamed tool metadata (bash output is persisted before tool.execute.after can redact it) #51937
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem: a plugin that redacts secrets in tool.execute.after can't reach the copies of bash output that were already persisted while the command was still running.
While output streams, bash calls ctx.metadata({ metadata: { output } }). Each update is saved as a running-state message.part.updated row in the event table of opencode.db, before tool.execute.after runs. Mutating output.output / output.metadata in the after-hook fixes the final part, the model context and the truncated-output file, but the streamed rows keep the raw value.
Load the plugin and have the model run printf SECRET-1234567890.
The tool result shows <redacted>.
sqlite3 ~/.local/share/opencode/opencode.db "select count(*) from event where instr(data, 'SECRET-1234567890') > 0" returns > 0.
Ask: either of these would let plugins close the gap:
a hook such as tool.execute.metadata, run on each ctx.metadata() update before it is published or persisted, which can mutate the metadata; or
an option not to persist running-state part updates, keeping only the final state.
Built-in redaction was declined in #19425 / #32183. This asks only for the hook, so plugins can do it themselves. We use it to mask 1Password op:// secrets that a plugin resolves for MCP auth.
@rekram1-node happy to send a PR for this if you'd take it.
Approach: add a tool.execute.metadata hook that runs where a tool's ctx.metadata() update is published and persisted, with { tool, sessionID, callID } as input and a mutable { title, metadata } output. That way a plugin can rewrite streamed bash output before it's written to the event table. It's a no-op when no plugin registers it. I'd include a test showing that a registered hook's changes land in the persisted part.
Activity
github-actions commentedon Sep 28, 2026
This issue might be related to existing issues. Please check:
r-d-w commentedon Oct 6, 2026
Checked these, none are duplicates:
ctx.metadata()) being persisted to theeventtable beforetool.execute.aftercan mutate them. A single hook on metadata updates, before publish/persist, would also cover the tool side of Feature request: pre-render stream/output filter hook for plugins #34035's live-render case.r-d-w commentedon Oct 6, 2026
@rekram1-node happy to send a PR for this if you'd take it.
Approach: add a
tool.execute.metadatahook that runs where a tool'sctx.metadata()update is published and persisted, with{ tool, sessionID, callID }as input and a mutable{ title, metadata }output. That way a plugin can rewrite streamed bash output before it's written to theeventtable. It's a no-op when no plugin registers it. I'd include a test showing that a registered hook's changes land in the persisted part.OK to proceed?