OpenProgram Docs

Event reference

Source of truth: EVENTS in openprogram/runtime/events/registry.py. Paths are under openprogram/. The label under an event is its origin, after its kind unless it is notify.

Turns and tools

EventPayloadWhen and from where
tool.beforegate · agent{tool, tool_call_id, args}Before each tool executes. A deny reason becomes the model's error tool result.
runtime/agent/loop/tool_dispatch.py
tool.resulttransform · tool{tool, tool_call_id, args, is_error}; value: result textBefore the result enters the model's context; only when a rewriter exists. Images and audio are kept.
runtime/agent/loop/tool_dispatch.py
tool.aftertool{tool, tool_call_id, is_error, result_text}After a tool call finishes. Text channel only.
runtime/agent/loop/tool_dispatch.py
turn.startsystem{session_id, user_msg_id, assistant_msg_id}User message persisted, Agent loop about to run.
runtime/conversation/turn_runtime/__init__.py
turn.endsystem{session_id, user_msg_id, assistant_msg_id, usage}Finalize completed.
runtime/conversation/turn_runtime/__init__.py
turn.stopgate · system{session_id, user_msg_id, assistant_msg_id, last_text (≤4000), stop_hook_active}After a completed top-level chat turn. A denial starts a continuation turn.
runtime/conversation/turn_runtime/stop_hook.py
user.prompt_submitteduser{msg_id, chars}User message row persisted.
runtime/conversation/turn_runtime/prep.py
model.response_startedagent{request_id}One provider request dispatched within the loop.
runtime/agent/loop/provider_lifecycle.py
model.response_completedagent{request_id, status, is_error}One response ended, on every exit. Per loop iteration, not per turn.
runtime/agent/loop/provider_lifecycle.py
file.changedtool{path, op}A file tool changed the tree. op: write, edit, patch; apply_patch also sends add, update, delete.
programs/tools/files/{write,edit,apply_patch,_remote}.py

Sessions and interaction

EventPayloadWhen and from where
session.startsystem{session_id, agent_id, channel}WebUI created a session.
interfaces/server/server_runtime/session_lifecycle.py
chat.before_senduser{session_id, msg_id, text, agent_id, attachments}Chat message persisted, about to enter the runtime.
interfaces/server/ws_actions/chat/turn.py
question.askedagent{session_id, question, …}The Agent asked through the question channel. Also sends a ws.frame.
runtime/agent/questions.py
mcp.request.cancelledsystem{request_id, execution_id, session_id, client_id, reason}An MCP prompt request was cancelled and cleaned up.
extensions/mcp/server/service.py
ws.framesystem{frame}Carries a rendered WebSocket frame to the WebUI without importing the server.
runtime/events/bus.py (emit_ws_frame)

Plugins, goals and scheduling

EventPayloadWhen and from where
plugin.enablesystem{plugin}Plugin loaded, contributions and hooks registered.
extensions/plugins/loader.py
plugin.disablesystem{plugin}About to unload; subscriptions still live.
extensions/plugins/loader.py
goal.updatesystem{session_id, goal: {goal_id, revision, text, status, phase, checklist, budget, usage, pause_reason, last_reason}}Goal state changed.
programs/tools/planning/goal/state.py
reminder.firedsystem{task_id, title, message, session_id, agent_id, wake, scheduled_for, fired_at}A reminder came due; shown, and wakes the Agent when wake is true.
runtime/scheduler/reminders.py
skills.changedsystem{}The skills watcher saw an install or update on disk.
interfaces/server/server.py
plugins.update_availablesystem{count}The update checker found newer versions. The registry documents {plugin, current, latest}.
interfaces/server/server.py

Context, memory and security

EventPayloadWhen and from where
context.compactedsystem{ok, tokens_before, tokens_after, reason}A compaction run finished.
runtime/context/engine.py
memory.degradedsystem{reason_code}Optional memory is unavailable for a turn.
runtime/conversation/memory_execution.py, state/memory/policy.py
memory.ingest_startedsystem{messages}The session watcher began a batch.
state/memory/session_watcher.py
memory.ingest_endedsystem{ok, retryable, reason, attempt?, next_attempt_at?}Ingest finished. retryable=false stops offering that session until it changes; a retry carries its attempt and when it comes.
state/memory/session_watcher.py
security.risky_tool_delegatedsystem{session_id, tool, source, authority}A delegated risky-tool check was allowed by bypass or an allow rule. No argument content; not an execution receipt.
runtime/permissions/audit.py
security.path_violationsystem{session_id, tool, reason}A delegated write-target check denied access. Fixed reason, no path.
runtime/permissions/audit.py

Channels and collaboration

EventPayloadWhen and from where
channel.message_inbounduser{channel, peer_kind, chars}An external message arrived.
interfaces/channels/inbound/_conversation.py
branch.message_sentagent{from, to}A message went to another session branch.
programs/tools/agents/send_message/send_message/send_message.py, programs/tools/agents/agent/agent/agent.py
agents.listedagent{sessions, branches}list_agents enumerated targets.
programs/tools/agents/send_message/list_agents/list_agents.py
subagent.startedsystem{job_id, label}A background Agent job entered running.
runtime/jobs/runner/shared.py
subagent.endedsystem{job_id, status, error}A background Agent job reached a terminal state.
runtime/jobs/runner/shared.py
branches.listedagent{session, count}Registry only: no emitter.
runtime/events/registry.py
sessions.listedagent{count}Registry only: no emitter.
runtime/events/registry.py

Bus calls

CallNote
get_event_bus() → EventBusWorker singleton.
create_event_bus()Independent instance; no disk writes.
make_event(type, origin, payload, metadata) → EventFills id, ts, session and turn.
emit_safe(type, origin, payload=None, metadata=None)Builds and emits; event-layer failures are swallowed.
emit_ws_frame(frame)Sends a ws.frame.
subscribe(handler, *, types=None) → unsubscribetypes=None receives every typed event.
subscribe_gate(type, fn) → unregisterPython gate.
emit_gate(event, timeout_s=None) → GateOutcomeAsks every gate.
subscribe_transform(type, fn) → unregisterRewriter.
emit_transform(event, value)Returns the final value.
register_tool_gate(gate) → unregisterShortcut for tool.before.
Examples
from openprogram.runtime.events import get_event_bus

def on_file_changed(event):
    print(event.payload["path"], event.metadata.get("session"))
unsubscribe = get_event_bus().subscribe(on_file_changed, types={"file.changed"})

def guard(event):
    if event.payload.get("tool") == "bash":
        return "policy denied this tool call"
    return None
remove = get_event_bus().subscribe_gate("tool.before", guard)

Unregistered types

TypeState
credential.cooldown, credential.rotated, credential.exhaustedTranslated from AuthEvent by bridges.py, payload {provider, credential, detail}. The bus tolerates them and warns once per type.
proactive.inject, proactive.prepare_requestedDerived events of the proactive engine, which is not installed.
question.replied, question.rejected, programs:changedFrame types inside ws.frame, not typed events. Spawns, attach cards, reports, notices, merges and deletions reach an open chat as transcript_update.

Reading the log

tail -f ~/.openprogram/logs/events.jsonl

A top-level turn usually shows user.prompt_submitted, turn.start, model.response_started, tool.before, tool.after, model.response_completed, turn.end. Failure, cancellation, tool calls and stop hooks change the order.

Event layer

Last updated · 2026-11-25