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.
What OpenReflex adds to OpenCode
Context in the system prompt
Relevant experience is added to the system prompt for the turn it applies to.
Alerts in tool output
Loop alerts are appended to the output of the tool call that triggered them.
Failures captured
Tool errors are read from OpenCode's message events, since the after-tool hook only runs on success.
Install OpenReflex for OpenCode
- 1
Install the OpenReflex CLI (Python 3.11 or newer)
$pipx install openreflex - 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 event | What OpenReflex does |
|---|---|
| chat.message | Starts a task and prepares the Execution Context. |
| tool.execute.before / after | Records each tool call and appends alerts to its output. |
| message.part.updated (error) | Records failed tool calls. |
| session.idle / session.compacted | Stores 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.