Skip to content

Integration guide

OpenReflex for OpenCode

OpenReflex installs a small OpenCode plugin that forwards session events to the local OpenReflex engine, plus an MCP server for direct queries.

The OpenReflex execution loop

The product behaviour is the same in every supported coding agent. Only the installation and hook transport differ.

01

Retrieve

Find similar past tasks, successful files and reusable lessons from local project memory.

02

Route

Score candidate approaches and recommend the best fit for success, cost, risk, uncertainty and the current budget.

03

Observe

Watch tool calls, verification, failures, context growth and progress, then intervene when the current path degrades.

04

Learn

Verify the outcome, record path, cost and regret, then turn successful resolutions into evidence for the next similar task.

Install OpenReflex for OpenCode

  1. 1

    Install the OpenReflex CLI (Python 3.11 or newer)

    $pipx install openreflex
  2. 2

    Add .opencode/plugins/openreflex.ts and the MCP server to opencode.json

    $openreflex install opencode

Check the setup any time with openreflex doctor. Nothing is recorded until a project is enabled.

How it works in OpenCode

Hook eventWhat OpenReflex does
chat.messageStarts a task and prepares the Execution Context.
tool.execute.before / afterRecords each tool call and appends alerts to its output.
message.part.updated (error)Records failed tool calls.
session.idle / session.compactedStores the outcome and lessons, and notes compaction.
  • If your project uses opencode.jsonc, add the MCP entry manually; OpenReflex does not rewrite JSONC files.
  • The OpenCode integration follows OpenCode's plugin API and is covered by OpenReflex's protocol and fuzz tests.

Common questions

Does the plugin need network access?
No. It runs the local openreflex command and never contacts a server.
Can I use only the MCP tools?
Yes. The MCP server works on its own, though live capture and alerts need the plugin.

Other integrations

Full CLI and MCP reference in the docs, and the source on GitHub.