fix(opencode): redact output.metadata, not just output.output - #9
Merged
Conversation
OpenCode's tool.execute.after hook exposes metadata as a separate mutable field alongside output. OpenCode populates metadata with a raw copy of the tool result and persists it to the session store (and includes it in --format json / opencode export) independently of output.output — so a secret fully redacted in the field the model sees could still survive in plaintext in session metadata. Confirmed live against real bash tool output in an OpenCode session. Redact metadata via the same RedactTreeToolOutput walker the claudecode/cursor/pi adapters already use for their tree-shaped payloads. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Logo + a short blurb, per Utkarsh's request in the open-sourcing Slack thread. Logo asset matches webflow/codeflow's, the other public Webflow repo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mohitbansal-webflow
approved these changes
Aug 27, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tool.execute.afterhook exposesoutputas three independently-mutable fields:title,output,metadata. ctxcop's bridge only ever redactedoutput.output— the field the model reads next turn.output.metadatawith a raw copy of the tool's result and persists it to the session store (and includes it in--format json/opencode export), independent ofoutput.output. A secret fully redacted in what the model sees could still sit in plaintext in session metadata.output.outputcame back correctly redacted whileoutput.metadata.outputstill carried three of the four raw values, byte-for-byte, in the exported session JSON.Fix
internal/harness/opencode/tool_execute_after.go: now also walks and redactsmetadataviaredact.RedactTreeToolOutput— the same tree-walkerclaudecode/cursor/pialready use for their tree-shaped payloads. OpenCode's adapter was the outlier because its hook contract splits output into a flat string plus a separate metadata field instead of one tree.internal/harness/opencode/extension/ctxcop.ts: forwardsoutput.metadatato the Go binary and reapplies the redacted result viareplaceInPlace, consistent with howtool.execute.beforealready preserves object identity forargs.CHANGELOG.md: Security entry under Unreleased.Also bundled: Webflow OSS branding
Added the Webflow logo + a short "Webflow Open Source" blurb to the README, matching
webflow/codeflow's pattern (same logo asset). Unrelated to the security fix — bundled at Andrew's request since we were touching the repo anyway.Test plan
go test ./internal/harness/opencode/...— addedTestToolExecuteAfterRedactsMetadataEvenWhenOutputClean, all existing tests pass unchanged.opencodebinary (v1.18.23) with the real plugin loader (Bun), both in a Linux container and interactively in a macOS terminal — confirmed via byte-level inspection of the session's exported JSON, not just what's rendered in the TUI.🤖 Generated with Claude Code