Adapt

Events

Event system, subscription patterns, and complete event reference.

Brain and its neurons emit events at every stage of the pipeline — observation, synthesis, querying, evolution, and more. You can subscribe to these events to build real-time UIs, trigger side effects (like notifying a user when something important is learned), debug pipeline behavior, or forward events to external systems.

Subscribing

// Specific event (typed)
brain.on('neuron:synthesized', (payload) => {
  console.log(`${payload.neuronId}: ${payload.significance} — ${payload.evolution}`)
})

// All events
brain.on((event) => {
  console.log(`[${event.type}] ${event.id} at ${event.timestamp}`)
})

Neuron events are automatically forwarded through Brain — subscribe on Brain, not individual neurons.

Forwarding to a UI

Events are useful for building real-time interfaces — showing users what the Brain is doing as it processes data:

// Forward all brain events to an Electron renderer
brain.on((event) => {
  window.webContents.send('brain:event', {
    type: event.type,
    ...event.payload,
  })
})

See Recipes — SSE Event Broadcasting for a server-sent events example.

Event Reference

Events are grouped by phase. The most commonly used events are neuron:synthesized (a neuron updated its knowledge), brain:ask:completed (a query finished), and evaluator:evaluation:completed (the evolution system made decisions).

Brain Events

PhaseEventsKey payload fields
Initbrain:init:started, brain:init:config:generating, brain:init:config:generated, brain:init:completed, brain:init:failedconfigs[], neuronIds[], usage
Injectbrain:inject:started, brain:inject:batch:started, brain:inject:batch:completed, brain:inject:completed, brain:inject:failedinjectId, itemCount, batchCount, results[]
Askbrain:ask:started, brain:ask:synthesis:started, brain:ask:completed, brain:ask:failedqueryId, query, insight, sources[], gaps[], usage
Neuron Mgmtbrain:neuron:added, brain:neuron:removedneuronId, name, instructions
Signalsbrain:signal:receivedsource, description, timestamp
Evaluatorevaluator:evaluation:started, evaluator:evaluation:completed, evaluator:evaluation:failedsignalCount, decisions[], reasoning
Evolutionevolution:action:started, evolution:action:executed, evolution:action:failedaction, targets[], reasoning, result
Configbrain:config:updatedupdates, changedFields[]

Neuron Events

PhaseEventsKey payload fields
Initneuron:init:started, neuron:init:completed, neuron:init:failedneuronId, systemPrompt, usage
Observeneuron:observe:started, neuron:observe:thinking, neuron:observed, neuron:observe:dismissed, neuron:observe:errorneuronId, output[], importance, bufferCount, gaps[]
Synthesizeneuron:synthesize:started, neuron:synthesize:thinking, neuron:synthesized, neuron:synthesize:dismissed, neuron:synthesize:errorneuronId, newUnderstanding, significance, evolution
Learnneuron:learn:failedneuronId, error
Queryneuron:query:started, neuron:query:completed, neuron:query:failed, neuron:query:thinkingneuronId, insight, relevance, confidence, gaps[]
Healthneuron:health:updatedneuronId, activation, status, previousStatus
Signalsneuron:signalneuronId, description, metrics
Configneuron:config:updated, neuron:prompts:regenerated, neuron:understanding:set, neuron:understanding:adjustedneuronId, changedFields[], directive, significance

Thinking Events

neuron:observe:thinking, neuron:synthesize:thinking, and neuron:query:thinking fire when the LLM produces intermediate reasoning. Payload includes thoughts: string[] and usage: TokenUsage. These are useful for two things: debugging (seeing why a neuron made a decision) and real-time UI feedback (streaming the neuron's thought process to users).

On this page