GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: plugin hook for streamed tool metadata (bash output is persisted before tool.execute.after can redact it) · Issue #51937 · anomalyco/opencode

[FEATURE]: plugin hook for streamed tool metadata (bash output is persisted before tool.execute.after can redact it) #51937

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[FEATURE]: plugin hook for streamed tool metadata (bash output is persisted before tool.execute.after can redact it)#51937
Copy link
Assignees
rekram1-node
Labels
pending closetriaging

Description

@r-d-w
r-d-w
opened on Sep 28, 2026
Issue body actions

Feature hasn't been suggested before.

  • 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.

Repro (1.18.18, macOS):

export const RedactDemo = async () => ({
  "tool.execute.after": async (_input, output) => {
    const scrub = (s: string) => s.replaceAll("SECRET-1234567890", "<redacted>")
    output.output = scrub(output.output)
    if (typeof output.metadata?.output === "string") output.metadata.output = scrub(output.metadata.output)
  },
})
  1. Load the plugin and have the model run printf SECRET-1234567890.
  2. The tool result shows <redacted>.
  3. 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.

Activity

  1. github-actions
    assigned
    rekram1-node
    on Sep 28, 2026
  2. github-actions commented on Sep 28, 2026

    @github-actions
    github-actionsBot
    on Sep 28, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be related to existing issues. Please check:

    • [FEATURE]: secrets redaction at tool output boundary #32183: Secrets redaction at the tool output boundary (closed as a duplicate of [FEATURE] Pre/post API call hooks in Provider interface for secret redaction and exfiltration prevention #19425).
    • [FEATURE] Pre/post API call hooks in Provider interface for secret redaction and exfiltration prevention #19425: Pre/post API call hooks for secret redaction and exfiltration prevention.
    • Feature request: pre-render stream/output filter hook for plugins #34035: A plugin hook to filter streamed output before it is rendered.
  3. r-d-w commented on Oct 6, 2026

    @r-d-w
    r-d-w
    on Oct 6, 2026
    Author
    More actions

    Checked these, none are duplicates:

    • [FEATURE] Pre/post API call hooks in Provider interface for secret redaction and exfiltration prevention #19425 / [FEATURE]: secrets redaction at tool output boundary #32183 ask for built-in or provider-level redaction. This asks only for a plugin hook.
    • Feature request: pre-render stream/output filter hook for plugins #34035 (closed for template, not on merits) wants a pre-render hook for streamed assistant text, a UI concern. This is about tool metadata updates (ctx.metadata()) being persisted to the event table before tool.execute.after can 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.
  4. r-d-w commented on Oct 6, 2026

    @r-d-w
    r-d-w
    on Oct 6, 2026
    Author
    More actions

    @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.

    OK to proceed?

  5. opencodejr commented on Oct 28, 2026

    @opencodejr
    opencodejrBot
    on Oct 28, 2026
    Contributor
    More actions

    Thanks for the detailed write-up and repro, @r-d-w!

    This was reported on 1.18.18, which is OpenCode v1. v1 now only gets fixes for critical bugs (data loss, security problems, crashes or breakage with no workaround). New plugin hooks like tool.execute.metadata, or an option not to save running-state part updates, are unlikely to be added to v1.

    OpenCode v2 (the @opencode/cli package, opencode command) is a separate implementation with its own plugin API (execute.before / execute.after tool hooks and streamed progress updates). We'd encourage upgrading. If you find the same gap there (streamed tool progress saved before a plugin can redact it), please open a new issue for v2 or reply here, and maintainers will look at it through the normal flow. Related: #19425 and #32183 (built-in redaction, declined).

  6. opencodejr
    added
    pending close
    triaging
    on Oct 28, 2026
  7. opencodejr
    closed this as not plannedon Oct 29, 2026
  8. opencodejr commented on Oct 29, 2026

    @opencodejr
    opencodejrBot
    on Oct 29, 2026
    Contributor
    More actions

    Closing this as not planned. The request (a hook to redact streamed ctx.metadata() updates before they're saved, or an option not to save running-state part updates) was reported on v1 (1.18.18). v1 only gets critical fixes, and we haven't heard back.

    Thanks again for the clear repro, @r-d-w. If v2 (@opencode/cli) has the same problem, where streamed tool progress is saved before a plugin's execute.after hook can redact it, please open a new issue with the v2 version and steps, and it will be looked at there.

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

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

pending closetriaging

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.