Harness Notes

Hooks

Updated 2026-11-24,

On this page

Which moments a hook can attach to, and what it can do there. Event names link to each harness’s documentation. “Block”, “deny” and “modify” change what the agent does; “observe only” can watch but not intervene. Where hook files live is on the Locations page.

MomentOpenCode 2.xPlugin hooks and events
Hook typesPlugin hooks and events
Session and workspace
Session starts
session.created

undocumented

observe only

Configuration changes
config.updated

undocumented

observe only

Worktree is resolved
worktree.resolved

undocumented

observe only

Worktree updates
worktree.updated

undocumented

observe only

Session details change
session.title

modify, replace

Setting result supplies the title.

session.renamed

undocumented

observe only

session.metadata.updated

undocumented

observe only

Session status changes
session.status

undocumented

observe only

Session is viewed
session.viewed

undocumented

observe only

Session is moved
session.moved

undocumented

observe only

Session goes idle
session.idle

undocumented

observe only

Session is forked
session.forked

undocumented

observe only

Session is deleted
session.deleted

undocumented

observe only

Server connects
server.connected

undocumented

observe only

Server shuts down
location.shutdown

undocumented

observe only

Prompt and turn
User submits a prompt
session.prompt

modify, block

Throwing stops prompt admission.

Message is queued
session.inbox.enqueued

undocumented

observe only

Queued message delivery changes
session.inbox.delivery.changed

undocumented

observe only

Queued message is delivered
session.inbox.delivered

undocumented

observe only

Queued message is cancelled
session.inbox.cancelled

undocumented

observe only

Agent is selected
session.agent.selected

undocumented

observe only

Agent starts
session.execution.started

undocumented

observe only

Model step starts
session.step.started

undocumented

observe only

Model step streams
session.step.streamed

undocumented

observe only

Model step ends
session.step.ended

undocumented

observe only

Model step fails
session.step.failed

undocumented

observe only

Skill is activated
session.skill.activated

undocumented

observe only

Turn is retried
session.retry

retry, decide

Overrides the retry decision for a provider failure.

session.retry.scheduled

undocumented

observe only

Turn is interrupted
session.execution.interrupted

undocumented

observe only

Turn fails
session.execution.failed

undocumented

observe only

Agent finishes its turn
session.experimental.idle

undocumented

add context

2.2.1+, experimental. Runs when a session finishes model work with no pending input, but not after an interruption, a failure or a manual compaction.

Input the hook adds continues the same execution. It reports background shells, subagents and image jobs still running. The built-in /goal loop uses it.

Agent ends
session.execution.succeeded

undocumented

observe only

Tools
Tool input starts streaming
session.tool.input.started

undocumented

observe only

Tool input streams
session.tool.input.delta

undocumented

observe only

Tool input is complete
session.tool.input.ended

undocumented

observe only

Before a tool runs
tool.execute.before

modify, block

Throwing blocks the tool.

Tool execution starts
session.tool.called

undocumented

observe only

Tool execution reports progress
session.tool.progress

undocumented

observe only

After a tool runs (any result)
tool.execute.after

modify

Receives completed or error status.

After a tool succeeds
session.tool.success

undocumented

observe only

After a tool fails
session.tool.failed

undocumented

observe only

Permissions and questions
Permission is requested
permission.evaluate

allow, deny, ask user, annotate

An explicitly configured deny is final and does not invoke the hook.

permission.asked

undocumented

observe only

Permission is answered
permission.replied

undocumented

observe only

Session permissions change
session.permissions

undocumented

observe only

Form is shown to the user
form.created

undocumented

observe only

User submits a form
form.replied

undocumented

observe only

User cancels a form
form.cancelled

undocumented

observe only

Shell, terminals and files
Before a shell command
shell.create.before

modify, set environment

Can change the command, working directory, timeout, shell and environment.

Shell command starts
session.shell.started

undocumented

observe only

After a shell command
session.shell.ended

undocumented

observe only

Background shell is created
shell.created

undocumented

observe only

Background shell exits
shell.exited

undocumented

observe only

Background shell is removed
shell.deleted

undocumented

observe only

Terminal is created
pty.created

undocumented

observe only

Terminal updates
pty.updated

undocumented

observe only

Terminal exits
pty.exited

undocumented

observe only

Terminal is removed
pty.deleted

undocumented

observe only

Persistent terminal is added
persistent-pty.added

undocumented

observe only

Persistent terminal is removed
persistent-pty.removed

undocumented

observe only

Watched file changes
filesystem.changed

undocumented

observe only

Revert is staged
session.revert.staged

undocumented

observe only

Revert is applied
session.revert.committed

undocumented

observe only

Staged revert is cleared
session.revert.cleared

undocumented

observe only

Git branch changes
vcs.branch.updated

undocumented

observe only

MCP
MCP server status changes
mcp.status.changed

undocumented

observe only

MCP resources change
mcp.resources.changed

undocumented

observe only

Context and compaction
Instructions are loaded
session.instructions.updated

undocumented

observe only

Before context is sent to the model
session.context

modify

System prompt, messages, tools and options for agent requests.

Before context is compacted
session.compaction

modify, replace

Setting result skips the model call.

session.compaction.started

undocumented

observe only

Compaction streams
session.compaction.delta

undocumented

observe only

After context is compacted
session.compaction.ended

undocumented

observe only

Compaction fails
session.compaction.failed

undocumented

observe only

Model and provider
Model is selected
session.model.selected

undocumented

observe only

Before provider headers are sent
session.model.request

modify

Headers and raw settings; can be scoped to one provider.

Before a provider request
session.generate

modify, replace

session.http.request

modify, replace

session.experimental.ws.send

modify

Experimental.

aisdk.sdk

undocumented

replace

Supplies the AI SDK provider instance.

aisdk.language

undocumented

replace

Supplies the language model instance.

After a provider response
session.http.response

modify, replace

Token usage updates
session.usage.updated

undocumented

observe only

Credentials change
credential.updated

undocumented

observe only

Active credential switches
credential.switched

undocumented

observe only

Provider list changes
provider.updated

undocumented

observe only

Model list changes
model.updated

undocumented

observe only

Model catalog refreshes
models-dev.refreshed

undocumented

observe only

Integration changes
integration.updated

undocumented

observe only

Messages and interface
Text starts streaming
session.text.started

undocumented

observe only

Text streams
session.text.delta

undocumented

observe only

Text is complete
session.text.ended

undocumented

observe only

Reasoning starts
session.reasoning.started

undocumented

observe only

Reasoning streams
session.reasoning.delta

undocumented

observe only

Reasoning ends
session.reasoning.ended

undocumented

observe only

Synthetic message is added
session.synthetic

undocumented

observe only

Text is added to the prompt
tui.prompt.append

undocumented

observe only

Interface command runs
tui.command.execute

undocumented

observe only

Toast is shown
tui.toast.show

undocumented

observe only

Session is selected in the interface
tui.session.select

undocumented

observe only

Plugins and configuration
Plugin updates
plugin.updated

undocumented

observe only

Project updates
project.updated

undocumented

observe only

Agent list changes
agent.updated

undocumented

observe only

Command list changes
command.updated

undocumented

observe only

Skill list changes
skill.updated

undocumented

observe only

References change
reference.updated

undocumented

observe only

Web search settings change
websearch.updated

undocumented

observe only

Update is available
installation.update-available

undocumented

observe only

Installation updates
installation.updated

undocumented

observe only

Definitions a plugin can edit
Tool definitions
tool.transform

undocumented

modify

Agent definitions
agent.transform

undocumented

modify

Command definitions
command.transform

undocumented

modify

Skill definitions
skill.transform

undocumented

modify

MCP server definitions
mcp.transform

undocumented

modify

Provider definitions
Model definitions
Integration definitions
integration.transform

undocumented

modify

Reference definitions
reference.transform

undocumented

modify

Web search definitions
websearch.transform

undocumented

modify

Worktree definitions
worktree.transform

undocumented

modify

Version control definitions
vcs.transform

undocumented

modify

Notes and sources

OpenCode 2.x
  • @opencode/cli 2.x, checked at 2.0.28. 1.x plugins do not run in 2.x.
  • Plugins register hooks per domain with ctx.<domain>.hook(name, callback); each callback receives one mutable event. Hooks run in plugin order.
  • Transforms are synchronous edits to registered definitions, replayed in registration order.
  • Events are read with ctx.event.subscribe() and can only be observed.
  • 2.1 renames provider replay data to native across text/reasoning lifecycle, tool and step/compaction events. Tool result native shallow-merges into call native; execution state is unchanged. SessionCompactionResult.providerState becomes native. session.compacted is removed; subscribe to current compaction lifecycle events.
  • 2.1 adds paginated ctx.session.list to both Effect and Promise plugin APIs.
  • 2.2.0 source: event.subscribe({types}) filters events by registered type; unknown types warn and are ignored. Plugin reload activation is awaited before model-step context preparation. Session instruction entry mutations use ctx.session.instructions.entry.*, independently of hook callbacks. Experimental desktop GUI plugins use a separate Electron/main and app renderer loader; this is not a CLI/TUI rendering guarantee.
  • 2.2.1 adds the experimental experimental.idle session hook (ctx.session.hook). Input added from it, such as a synthetic message, continues the same execution instead of letting the session go idle. The built-in /goal plugin is its first user.
  • 2.2.4+ schedule lifecycle, traced at 2.2.7: ServerProcess.start forks Schedule.run outside the optional managed lifecycle branch, including opencode serve/standalone servers. A SQLite lease elects one scheduler per database; experimental.schedules remains checked at fire time. This is a core background scheduler, not a new plugin hook event; no firing probe.
  • Since 2.3.1, schedules become experimental automations: use experimental.automations (schedules remains an alias), /automation and automation_* tools. Triggers support time/interval/cron or MCP push events, with prompt or Code Mode actions. Event triggers also require mcp_events. Every server starts the automation loop. Migration keeps only active/paused plain-prompt schedules without conditions/run limits and with a next due time; it drops the old table. Prior schedule findings describe 2.2.x. No scheduler or migration runtime probe.
  • In 2.4.0, automations use the top-level automations setting. Set it to false to disable timer, cron and MCP-event automations.