Skip to content

[BUG] OpenCode plugin registers experimental.* hooks not present in Plugin API — autoRecall silently broken on 1.16.2 #2656

Description

@clayleopardlabs

Bug Description

The @vectorize-io/opencode-hindsight plugin (tested on v0.2.5 and v0.2.7) registers three hooks that are not part of the @opencode-ai/plugin public Plugin API in OpenCode 1.16.2. OpenCode silently ignores unknown hook names — no error, no warning — so the following features are completely non-functional:

  • experimental.chat.system.transformautoRecall never fires
  • experimental.session.compactingmemory injection during compaction never fires
  • (The event hook for session.idle autoRetain does work, as it's a supported hook)

This is distinct from the execution-ordering issue described in #1758 item #2 (which was about session.created vs system.transform firing order). The code in v0.2.5+ already implements the #1758 fix (it doesn't depend on session.created), but it doesn't matter — the hook itself is never called.

Environment

Component Version
OpenCode 1.16.2
@vectorize-io/opencode-hindsight 0.2.5 (also confirmed on 0.2.7)
@opencode-ai/plugin ^1.3.13
OS Windows 11

Root Cause

The plugin registers hooks using the "experimental." prefix namespace in hindsight-integrations/opencode/src/hooks.ts. These hooks (experimental.chat.system.transform, experimental.session.compacting) are not defined in the @opencode-ai/plugin type definitions.

The Hooks type in @opencode-ai/plugin only exposes: tool, auth, event, config, chat.message, chat.params, permission.ask, tool.execute.before, tool.execute.after. There are no experimental.* entries.

The plugin's own HindsightHooks interface defines these names locally (not imported from the Plugin SDK) and returns them in the hooks object. OpenCode silently discards any hook key it doesn't recognize — these hooks are registered but never invoked.

Impact

Feature Hook Status
autoRecall — injects relevant memories at session start experimental.chat.system.transform Never called
memory injection during compaction experimental.session.compacting Never called
autoRetain — saves conversation on idle events event (session.idle) Works (supported hook)

Users are not notified that autoRecall is broken. The plugin loads without errors, logs nothing unusual, and appears to be working — but the hindsight_memories context block never appears in the system prompt.

Steps to Reproduce

  1. Install @vectorize-io/opencode-hindsight v0.2.5+ in OpenCode 1.16.2
  2. Enable autoRecall: true in plugin config
  3. Start a session and chat — no <hindsight_memories> context appears in the system prompt
  4. Check plugin logs — no errors or warnings about unrecognized hooks
  5. Inspect @opencode-ai/plugin type definitions — confirm experimental.* hooks are absent

Evidence

Related Issues

Suggested Fixes

  1. Add experimental.chat.system.transform and experimental.session.compacting to the OpenCode Plugin API — these hooks appear to have been designed but never shipped in the public interface
  2. Alternative for autoRecall: Use the supported event hook to detect session creation and trigger initial recall from there
  3. Fallback: At minimum, the plugin should detect at startup whether the hooks it depends on are actually available and log a clear warning

Metadata

Metadata

Assignees

No one assigned

    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