OpenProgram Docs

Wiring the proactive layer into the code

The design is in Proactive layer and wins on any conflict. openprogram/runtime/events/bus.py is the event layer; taps sit in the source files that already know when something happened. Event has three core fields plus open metadata, so turn and session travel there and a source with no turn invents none.

Reused mechanisms

Design roleMechanismLocation
Event fan-outEventBusruntime/events/bus.py
Gate's askwrap_with_approval; a denial returns an is_error tool resultruntime/permissions/approvals/approval.py
Prepare background taskJobRunner.spawn_jobruntime/jobs/runner/
Inject landingMemory prefetch and steering messagesruntime/agent/loop/
Causality, rewind, branchingSession DAG, nodes carry parent_id and callerruntime/context/git/
Hard enforcement point_execute_tool_callsruntime/agent/loop/tool_dispatch.py

Event taps

EventSource
user.prompt_submittedruntime/conversation/turn_runtime/prep.py
model.response_started, model.response_completedruntime/agent/loop/provider_lifecycle.py
tool.beforetool_dispatch.py, before every execute. One event feeds the notify emit and the gate query
tool.aftertool_dispatch.py, after every call
subagent.started, subagent.endedruntime/jobs/runner/shared.py
file.changedAfter a successful write in programs/tools/files/: write.py, edit.py, apply_patch.py, _remote.py
External sourcesruntime/context/engine.py (compaction), interfaces/channels/inbound/_conversation.py, state/memory/session_watcher.py, web server skills and plugins routes; auth through runtime/events/bridges.py, installed idempotently at worker start

emit_ws_frame carries web frames over the bus and interfaces/server/server.py forwards them, so the job runner, sub-agent run, worktree manager, functions watcher and channel broadcast do not import the web UI.

Gate mounts

Chat pathAgentic nested path
Mountdecide_tool_gate in _execute_tool_calls, ahead of tool.execute_pre_invocation_hooks in runtime/agent/call_state.py, beside the cancel check
GuaranteeHard: every chat tool call passes hereOptional: a mount point, with no claim of total coverage

The gate query does not read permission_mode, so it also applies to sub-agent turns in any mode (invariants, execution model).

Prepare

Designed to use JobRunner.spawn_job with an allowlist excluding bash, write and network tools, in a separate pool of 1–2, preemptible by user tasks, yielding on 429. Today the engine emits proactive.prepare_requested and proactive.inject events; nothing yet spawns the task or lands the steering message.

Known gap

@function tool execution writes no DAG node; only Agent methods do. The DAG is therefore incomplete as a causal record, and audit relies on the full event set in events.jsonl instead.

Checking a wiring change

py_compile, relevant unit tests, a deploy to the development instance, healthy /healthz, one real message through the Web UI (npm --prefix apps/web run build first for frontend changes). For ordering, run a turn with a tool call and read the session's events.jsonl:

user.prompt_submitted → model.response_started → tool.before → tool.after → model.response_completed

Each entry carries session and turn in metadata.

Implementation status

PartState
Bus, taps, bridges, Web UI as subscriberImplemented
runtime/proactive/, engine.py::install_proactive, policies/Implemented, not installed: operations/worker/runner.py installs only the event bridges
Sync query pointregister_tool_gate, decide_tool_gate, ToolGateDenied in runtime/events/tool_gate.py
Teststests/component/agent/turns/test_event_bus.py, tests/unit/agent/execution/test_tool_gate.py, tests/unit/agent/behavior/test_event_bridges.py, test_proactive_engine.py, test_proactive_policies.py
Not claimedInstalled-App and live WebSocket acceptance

Project skills resolve from the process working directory; a worker started in the home directory reads ~/skills.

Last updated · 2026-11-25