Skip to main content
Polpo emits typed events for everything it does — task transitions, agent activity, assessments, deadlocks, notifications, and more. Events are streamed via SSE and WebSocket to all connected clients and optionally persisted to a log store.
Events marked with Not persisted are excluded from the log store because they fire too frequently. All other events are automatically persisted when a LogStore is attached.

Task Lifecycle

Core events for task creation, state transitions, updates, and removal.
EventDescriptionKey Payload Fields
task:createdTask added to the registrytask: Task
task:transitionTask status changedtaskId, from: TaskStatus, to: TaskStatus, task: Task
task:updatedTask fields modified (description, assignment, etc.)taskId, task: Task
task:removedTask deleted from registrytaskId
// Example: listen for status changes
orchestrator.on("task:transition", ({ taskId, from, to, task }) => {
  console.log(`Task ${taskId}: ${from}${to}`);
});

Agent Lifecycle

Events tracking agent process spawning, completion, and real-time activity.
EventDescriptionKey Payload Fields
agent:spawnedAgent process launched for a tasktaskId, agentName, taskTitle
agent:finishedAgent process exitedtaskId, agentName, exitCode, duration, sessionId?
agent:activityTool call or progress update from an agenttaskId, agentName, tool?, file?, summary?
orchestrator.on("agent:finished", ({ taskId, agentName, exitCode, duration }) => {
  console.log(`${agentName} finished task ${taskId} in ${duration}ms (exit: ${exitCode})`);
});

Assessment

Events for the assessment lifecycle — started, progress updates, completion, and expectation corrections.
EventDescriptionKey Payload Fields
assessment:startedAssessment began for a tasktaskId
assessment:progressStatus update during assessmenttaskId, message
assessment:completeAssessment finishedtaskId, passed: boolean, scores?: DimensionScore[], globalScore?: number, message?
assessment:correctedExpectations auto-corrected by the judgetaskId, corrections: number
The DimensionScore type:
{
  dimension: string;     // e.g. "correctness"
  score: number;         // 1-5
  reasoning: string;     // chain-of-thought explanation
  weight: number;        // weight used for global score
}

Orchestrator

Events for the orchestrator’s own lifecycle.
EventDescriptionKey Payload Fields
orchestrator:startedOrchestrator startedorg, agents: string[]
orchestrator:tickPeriodic aggregate counts (Not persisted)pending, running, done, failed, queued
orchestrator:deadlockUnresolvable deadlocks foundtaskIds: string[]
orchestrator:shutdownGraceful shutdown initiated(empty)
orchestrator:tick fires every 5 seconds and includes a queued count in addition to pending, running, done, and failed.

Retry & Fix

Events for the multi-stage retry system: fix attempts, full retries, and exhaustion.
EventDescriptionKey Payload Fields
task:retryFull retry startedtaskId, attempt, maxRetries
task:retry:blockedAutomatic retry/fix blocked (task has sideEffects: true)taskId, reason
task:fixFix phase started (targeted corrections)taskId, attempt, maxFix
task:maxRetriesAll retries exhaustedtaskId

Question Detection

Events for agent questions and auto-resolution.
EventDescriptionKey Payload Fields
task:questionAgent asked a question during executiontaskId, question
task:answeredOrchestrator auto-answered a questiontaskId, question, answer

Deadlock Resolution

Events for detecting and resolving dependency deadlocks.
EventDescriptionKey Payload Fields
deadlock:detectedBlocked tasks found with failed dependenciestaskIds: string[], resolvableCount
deadlock:resolvingAttempting to resolve a specific blocked tasktaskId, failedDepId
deadlock:resolvedDeadlock successfully resolvedtaskId, failedDepId, action: "absorb" | "retry", reason
deadlock:unresolvableDeadlock cannot be resolvedtaskId, reason

Resilience

Events for timeout and stale agent detection.
EventDescriptionKey Payload Fields
task:timeoutTask exceeded its maxDurationtaskId, elapsed, timeout
agent:staleAgent hasn’t reported activity recentlytaskId, agentName, idleMs, action: "warning" | "killed"

Recovery

Events for task recovery after restarts.
EventDescriptionKey Payload Fields
task:recoveredOrphaned task recovered on restarttaskId, title, previousStatus: TaskStatus

Missions

Events for mission lifecycle management.
EventDescriptionKey Payload Fields
mission:savedMission created or updatedmissionId, name, status: MissionStatus
mission:executedMission group started executionmissionId, group, taskCount
mission:completedAll tasks in a mission group finishedmissionId, group, allPassed: boolean, report: MissionReport
mission:resumedMission resumed from a previous runmissionId, name, retried, pending
mission:deletedMission deletedmissionId

Chat / Sessions

Events for the conversational chat interface.
EventDescriptionKey Payload Fields
session:createdNew chat session createdsessionId, title?
message:addedMessage added to a sessionsessionId, messageId, role: "user" | "assistant"

Approval Gates

Events for human-in-the-loop approval workflows.
EventDescriptionKey Payload Fields
approval:requestedApproval request createdrequestId, gateId, gateName, taskId?, missionId?
approval:resolvedApproval resolvedrequestId, status: "approved" | "rejected", resolvedBy?
approval:revisedTask sent back for reworkrequestId, taskId?, feedback, revisionCount, resolvedBy?
approval:timeoutApproval timed outrequestId, action: "approve" | "reject"

Escalation

Events for the 4-level escalation chain (agent retry, fallback agent, orchestrator LLM, human).
EventDescriptionKey Payload Fields
escalation:triggeredEscalation level activatedtaskId, level, handler, target?
escalation:resolvedEscalation level completedtaskId, level, action
escalation:humanHuman notification senttaskId, message, channels?

SLA & Deadlines

Events for monitoring task and mission deadlines.
EventDescriptionKey Payload Fields
sla:warningApproaching deadlineentityId, entityType: "task" | "mission", deadline, elapsed, remaining, percentUsed
sla:violatedDeadline exceededentityId, entityType: "task" | "mission", deadline, overdueMs
sla:metCompleted within deadlineentityId, entityType: "task" | "mission", deadline, marginMs

Quality Gates

Mission-level quality gate events.
EventDescriptionKey Payload Fields
quality:gate:passedQuality gate passedmissionId, gateName, avgScore?
quality:gate:failedQuality gate failedmissionId, gateName, avgScore?, reason
quality:threshold:failedMission average score below thresholdmissionId, avgScore, threshold

Scheduling

Events for cron-based mission scheduling.
EventDescriptionKey Payload Fields
schedule:triggeredScheduled mission triggeredscheduleId, missionId, expression
schedule:createdSchedule registeredscheduleId, missionId, nextRunAt?
schedule:completedScheduled run completedscheduleId, missionId

Notifications

Events for the notification router.
EventDescriptionKey Payload Fields
notification:sentNotification dispatched successfullyruleId, channel, event
notification:failedNotification dispatch failedruleId, channel, error

General

EventDescriptionKey Payload Fields
logGeneral log messagelevel: "info" | "warn" | "error" | "debug", message

Subscribing to Events

SSE (HTTP)

const events = new EventSource('/api/v1/projects/my-project/events');
events.onmessage = (e) => {
  const { event, data } = JSON.parse(e.data);
  // event: "task:transition", data: { taskId: "...", ... }
};

WebSocket

const ws = new WebSocket('ws://localhost:3000/api/v1/projects/my-project/ws');
ws.send(JSON.stringify({ type: 'subscribe', pattern: 'task:*' }));
ws.onmessage = (e) => {
  const { event, data } = JSON.parse(e.data);
};

Node.js (TypedEmitter)

import { TypedEmitter } from "polpo";

orchestrator.on("task:transition", ({ taskId, from, to, task }) => {
  console.log(`Task ${taskId}: ${from}${to}`);
});

// Glob-style patterns work for notifications
// (see Notifications guide for details)