Skip to main content

Module event_stream

Module event_stream 

Source
Expand description

Event Stream Module

Structured JSONL event sourcing for agent sessions. Every agent turn, tool call, and handoff is captured as an append-only event stream with byte-range offsets for efficient random access replay.

§Event Schema

{
  "recorded_at": "2026-02-13T04:16:56.465006066+00:00",
  "workspace": "/home/riley/A2A-Server-MCP",
  "session_id": "36d04218-2a47-4fbe-8579-02c21be775bc",
  "role": "tool",
  "agent_name": null,
  "message_type": "tool_result",
  "content": "✓ bash",
  "tool_name": "bash",
  "tool_success": true,
  "tool_duration_ms": 22515
}

§File Naming Convention

Files are named with byte-range offsets to enable random access: {timestamp}-chat-events-{start_byte}-{end_byte}.jsonl

This allows seeking to any point in a session without reading the entire log.

§S3/R2 Archival

The module supports automatic archival to S3-compatible storage:

use codetether_agent::event_stream::s3_sink::S3Sink;

let sink = S3Sink::from_env().await?;
sink.upload_file(&local_path, &session_id).await?;

Modules§

s3_sink
S3/R2 Object Storage Sink for Event Streams

Structs§

ChatEvent
A single event in the JSONL event stream
EventFile
File metadata for byte-range indexed JSONL
EventStreamWriter
Event stream writer that manages append-only JSONL with byte-range tracking

Enums§

EventCategory
Categories of events in the stream