Sessions Are Event Streams — But We Can't Query Them
Every OpenClaw session produces a rich stream of events: messages, tool calls, compactions, spawns, errors. These are stored in .jsonl files — append-only, ordered, timestamped. This is event sourcing by accident.
But there's no API to query this stream. The only option is to parse raw .jsonl files, which means:
- No way to ask "what tools did this agent call in the last hour?"
- No way to aggregate "how many errors across all sessions today?"
- No way to build dashboards, alerts, or analytics without custom file parsing
- The richest data source in OpenClaw is effectively invisible
Proposed: Session Event Query API
Tool-Level (for agents)
// Query own session events
session_events({
types: ["tool_call", "error"], // filter by event type
since: "2026-02-15T10:00:00Z", // time range
limit: 50 // pagination
})
// Query across sessions (for orchestrators)
sessions_events({
sessionKey: "agent:main:*", // wildcard
types: ["spawn", "complete"],
since: "1h" // relative time
})
HTTP API (for external systems)
GET /api/sessions/:key/events?types=error,tool_call&since=1h&limit=100
GET /api/events?agentId=main&types=spawn,complete&since=24h
Event Types to Expose
| Event |
Payload |
Use Case |
message |
role, tokens, model |
Usage tracking, conversation analysis |
tool_call |
tool name, duration, success/fail |
Tool reliability monitoring |
tool_error |
tool name, error message |
Alert on repeated failures |
compaction |
before/after tokens, summaryLength |
Context management insights |
spawn |
child sessionKey, task, model |
Orchestration tracking |
complete |
result, duration, tokens |
Pipeline completion |
model_switch |
from, to, reason |
Failover monitoring |
Why This Enables Everything Else
This is foundational infrastructure. Without queryable events:
Event sourcing is the #1 pattern in distributed systems (Kafka, EventStore, Axon). OpenClaw already HAS the event log — it just needs an API on top.
Minimal First Step
Expose the existing .jsonl content via a read-only session_events tool with type filtering and time range. No new storage, no new indexing — just structured access to what's already there.
Happy to help design the schema and test on Windows.
Sessions Are Event Streams — But We Can't Query Them
Every OpenClaw session produces a rich stream of events: messages, tool calls, compactions, spawns, errors. These are stored in
.jsonlfiles — append-only, ordered, timestamped. This is event sourcing by accident.But there's no API to query this stream. The only option is to parse raw
.jsonlfiles, which means:Proposed: Session Event Query API
Tool-Level (for agents)
HTTP API (for external systems)
Event Types to Expose
messagetool_calltool_errorcompactionspawncompletemodel_switchWhy This Enables Everything Else
This is foundational infrastructure. Without queryable events:
Event sourcing is the #1 pattern in distributed systems (Kafka, EventStore, Axon). OpenClaw already HAS the event log — it just needs an API on top.
Minimal First Step
Expose the existing
.jsonlcontent via a read-onlysession_eventstool with type filtering and time range. No new storage, no new indexing — just structured access to what's already there.Happy to help design the schema and test on Windows.