session

package
v0.0.0-...-e7f9e95 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkpoint

type Checkpoint struct {
	RunID        string                   `json:"run_id"`
	TaskName     string                   `json:"task_name"` // empty for adhoc tasks
	Iteration    int                      `json:"iteration"`
	Messages     []anthropic.MessageParam `json:"messages"`
	SystemPrompt string                   `json:"system_prompt"` // stored for debugging context
	InputTokens  int64                    `json:"input_tokens"`
	OutputTokens int64                    `json:"output_tokens"`
	CreatedAt    time.Time                `json:"created_at"`
}

Checkpoint captures the agent's conversation state at a point in time. Persisted to disk after each iteration so that failed runs can resume.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store persists and retrieves session checkpoints on the filesystem. Each run gets exactly one checkpoint file that is overwritten each iteration.

func NewStore

func NewStore(dir string) (*Store, error)

NewStore creates a new session store backed by the given directory. Creates the directory if it doesn't exist.

func (*Store) Delete

func (s *Store) Delete(runID string) error

Delete removes a checkpoint file. Called after successful task completion. Returns nil if the file doesn't exist (idempotent).

func (*Store) HasCheckpoint

func (s *Store) HasCheckpoint(runID string) bool

HasCheckpoint returns true if a checkpoint exists for the given RunID.

func (*Store) List

func (s *Store) List() ([]Checkpoint, error)

List returns all checkpoints in the store, sorted by creation time (newest first). Reads only metadata — does not load full message histories.

func (*Store) Load

func (s *Store) Load(runID string) (*Checkpoint, error)

Load reads a checkpoint from disk for the given RunID. Returns an error if no checkpoint exists.

func (*Store) Save

func (s *Store) Save(cp *Checkpoint) error

Save persists a checkpoint to disk, overwriting any previous checkpoint for the same RunID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL