Context
When an agent goes offline or fails a quest, there's no way to see what events led to the failure. A per-agent event replay buffer (last 50 events) enables post-mortem debugging without external logging infrastructure.
What to implement
Ring buffer per agent
Store the last 50 OS events (any type) for each agentId:
interface ReplayEvent {
type: string // e.g. 'agent.status', 'quest.completed'
payload: object
recordedAt: string // ISO timestamp
}
Implemented as a fixed-size ring buffer — oldest entry dropped when full.
Route: GET /api/agents/:id/replay
Returns the agent's event buffer, newest first:
{ "agentId": "bot-1", "events": [...], "bufferSize": 50, "count": 23 }
Route: DELETE /api/agents/:id/replay
Clears the buffer (useful for test isolation).
Acceptance criteria
Context
When an agent goes offline or fails a quest, there's no way to see what events led to the failure. A per-agent event replay buffer (last 50 events) enables post-mortem debugging without external logging infrastructure.
What to implement
Ring buffer per agent
Store the last 50 OS events (any type) for each agentId:
Implemented as a fixed-size ring buffer — oldest entry dropped when full.
Route: GET /api/agents/:id/replay
Returns the agent's event buffer, newest first:
{ "agentId": "bot-1", "events": [...], "bufferSize": 50, "count": 23 }Route: DELETE /api/agents/:id/replay
Clears the buffer (useful for test isolation).
Acceptance criteria
count: 0{ events: [], count: 0 }