Skip to content

Feature request: pre-storage message transform hook (experimental.message.store.before) #28223

Closed as not planned

Description

@glassdimlygr

Problem

Plugins that perform PII/secret redaction (like vibeguard) currently use experimental.chat.messages.transform to redact content before it reaches the LLM API. However, this hook fires after the message is already persisted to the SQLite database.

This means sensitive data (passwords, API keys, PII) is stored in plaintext on disk in ~/.local/share/opencode/opencode.db — even though it never reaches the LLM.

There is no SDK method to update stored message parts after the fact, and the message.part.updated event is read-only.

Proposed Solution

Add a new hook:

"experimental.message.store.before": async (input, output) => {
  // output.parts is the array of message parts about to be persisted
  // Plugin can modify part.text, state.output, etc. in-place
  // Modified content is what gets written to the DB
}

This would fire before the message/part is written to the database, allowing privacy plugins to redact content before it ever touches disk.

Use Case

The opencode-vibeguard plugin detects and redacts PII/secrets using regex + AI (local NER model). It needs to ensure passwords and tokens never persist to disk — not just that they are hidden from the LLM.

Current Workaround

The only option today is direct SQLite manipulation after the message.part.updated event fires, which is fragile and couples to internal schema details.

Additional Context

  • The existing experimental.chat.messages.transform hook signature would work identically — just firing at a different lifecycle point
  • This would make OpenCode viable for enterprises with data-at-rest compliance requirements (SOC 2, GDPR right-to-erasure, etc.)

Activity

  1. github-actions commented on May 18, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature request titles must start with [FEATURE]: (e.g. [FEATURE]: pre-storage message transform hook)
    • The feature request template requires a verification checkbox confirming you've searched for existing issues

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on May 18, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions