Planck.Agent.TurnState (Planck.Agent v0.1.8)

Copy Markdown View Source

Tracks the agent's turn counter and checkpoint stack.

:index increments on every new LLM turn. :checkpoints is a reversed list of message-list lengths recorded at the start of each user prompt — used to detect messages appended mid-turn and to rebuild state after a session reload.

Summary

Functions

Increment the turn counter.

Return a fresh turn state.

Push a checkpoint (current message-list length) onto the stack.

Rebuild checkpoints from a message list, preserving the current index.

Types

t()

@type t() :: %Planck.Agent.TurnState{
  checkpoints: [non_neg_integer()],
  index: non_neg_integer()
}
  • :index — monotonically increasing turn counter
  • :checkpoints — reversed stack of message-count checkpoints, one per user prompt

Functions

advance(turn_state)

@spec advance(t()) :: t()

Increment the turn counter.

new()

@spec new() :: t()

Return a fresh turn state.

push_checkpoint(turn_state, length)

@spec push_checkpoint(t(), non_neg_integer()) :: t()

Push a checkpoint (current message-list length) onto the stack.

rebuild_checkpoints(turn_state, messages)

@spec rebuild_checkpoints(t(), [term()]) :: t()

Rebuild checkpoints from a message list, preserving the current index.