Events
Three books of events
Choosing the right event domain is the first decision for most changes. Keep journal facts, live intercom calls, and capability policy in the right book.
session
Session events · Journal
Facts written down and preserved across restarts.
Use when:The fact must survive a reload
turn/start · turn/endOpen and close a turn
step/start · step/endOne think-and-act step
user/messageInput entering a step (surface)
assistant/chunk · assistant/messageLive notes and clean copy
tool/call · tool/resultAction and report card
request/headerThe frozen request envelope
session/eventBroadcast every log event
agent
Agent events · Intercom
Live calls during work that do not enter the journal body.
Use when:Observe or intercept in-flight work
agent/inbox/*inserted / claimed / discarded / spliced
agent/statusidle ⇄ running
agent/pre-stepwaterfall: reject or rewrite claimed input
agent/requestwaterfall: change the model, not the essay
agent/request-errorwaterfall: retry or let failure through
agent/turn-stoppingserial: the final chance to add a note
capability
Capability events · Rules
Attach policy to a socket without entering the heartbeat room.
Use when:Add policy and adapters to a seam
llm/streamwaterfall: wrap the adapter stream
tools/pre-executeallow / deny / ask
tools/executewrap the tool function with timeouts or metrics
tools/post-executeaccept / replace / block
fs/write-intent · fs/edit-intentobserve before writes
fs/observedemit: synchronous bookkeeping after a read or write succeeds
system-prompt/assemblefinal prompt assembly
The tool pipeline
- 01createExecution: freeze arguments
- 02tools/pre-execute waterfall: allow / deny / ask
- 03If ask → ctx.approval
- 04ToolGuard[]: may only tighten policy
- 05tools/execute waterfall: timeout wraps tool.execute
- 06tools/post-execute: accept / replace / block
- 07finalizeContent: last model-visible edit; must not throw
- 08tools/result emit: freeze the report card
The four dispatch modes, once more
emitBroadcast: listeners may observe but cannot veto.
waterfallCall next() to pass the paper inward; otherwise you take control.
parallelThe whole class works at once, such as flushing the journal to disk.
serialTake turns speaking, with no next(). turn-stopping uses this mode.