Principle:A5c ai Babysitter Session Event Persistence
| Knowledge Sources | |
|---|---|
| Domains | Kubernetes, Event_Sourcing, Session_Management |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
A method for persisting agent session events from SSE streams with budget enforcement and transcript accumulation.
Description
Session Event Persistence is the principle of processing real-time SSE events from agent pod execution and mutating the dispatch run state in place. Each event updates:
- AgentDispatchRun status (Running → Completed/Failed)
- AgentDispatchAttempt status
- AgentSessionTranscript with accumulated messages and cost
Budget checks run after each event. Terminal events (run-complete) emit notifications. Budget exceeded → run Failed with budget_exceeded reason.
Usage
Use this principle when collecting agent execution results via SSE callbacks in a Kubernetes dispatch system.
Theoretical Basis
The persistence is an event loop over the SSE stream:
for event in sseStream:
persistSessionEvent(event, run, attempt, transcript)
run.status = updated
transcript.cost += estimateCost(event)
if budgetExceeded: run.status = Failed(reason=budget_exceeded)
if terminalEvent: emit notification; break
Key property: The run and attempt are mutated in place, not replaced — this preserves the K8s resource identity while updating status fields, enabling live status queries.