Tasks & events

Shipped in v3-alpha (Beta). Tasks and events are first-class memory primitives. Interfaces may still change before 3.0 stable.

Tasks — intent + outcome → strategies

A task isn’t just a TODO. It’s a memory unit that tracks intent, progress, and outcome. When completed, the system auto-extracts a strategy and a fact.

Task created → "Fix billing webhook timeout"
    ↓ (agent works on it)
Task completed → "Fixed by increasing timeout to 30s"
    ↓ (auto-extraction)
Strategy → "When webhook timeouts occur, check timeout config first"
Fact → "Billing webhook timeout is 30s (was 10s)"
Episode → links task + strategy + fact with temporal context

State machine

                ┌──────────┐
                │ pending  │
                └────┬─────┘
                     │ start
                     ▼
                ┌──────────┐
        ┌───── │in_progress│ ─────┐
        │      └────┬─────┘      │
        │ block     │ complete   │ delegate
        ▼           ▼            ▼
   ┌────────┐ ┌──────────┐ ┌──────────┐
   │blocked │ │completed │ │delegated │
   └───┬────┘ └──────────┘ └────┬─────┘
       │ unblock                  │ (other agent completes)
       ▼                          ▼
   ┌──────────┐             ┌──────────┐
   │in_progress│             │completed │
   └──────────┘             └──────────┘

   Any state → cancelled (explicit)

Multi-agent coordination

// Agent A delegates to Agent B
await mnemo.createTask({
  title: "Review PR #234 for security issues",
  assignedTo: "agent-b",
  delegatedBy: "agent-a",
  relatedFacts: ["fact_123"],
  dueAt: new Date(Date.now() + 3600000),
});
 
// Agent B picks up via WebSocket subscription, completes:
await mnemo.updateTask(taskId, {
  status: "completed",
  outcome: "Found 2 SQL injection vulnerabilities in routes/user.ts",
  lessonsLearned: "Always check parameterized queries in new routes",
});
 
// Auto-extracted:
// → Strategy: "Review new routes for parameterized queries"
// → Event: "Security review completed for PR #234"

Events — immutable temporal anchors

await mnemo.recordEvent({
  type: "external",
  name: "deploy.production.success",
  source: "github-actions",
  description: "v2.3.1 deployed to production",
  metadata: { commit: "abc123", duration: 180 },
  relatedEntities: ["entity_prod_cluster"],
});
 
// Events trigger memory updates via plugins:
// - On deploy.success → close any open "deploy broken" facts
// - On user.feedback.negative → decrease worth of last-used strategies

API surface

POST   /v1/memory/tasks                 Create
PATCH  /v1/memory/tasks/:id             Update state
GET    /v1/memory/tasks                 List (filter by agent/status)
POST   /v1/memory/tasks/:id/delegate    Delegate to another agent

POST   /v1/memory/events                Record event
GET    /v1/memory/events                Query (time range)

See also