Skip to main content

Module conversation

Module conversation 

Source
Available on crate feature conversation only.
Expand description

Multi-turn conversation helper.

Conversation holds the system prompt, message history, default request settings, and accumulated usage for a multi-turn exchange. Each call to Conversation::send runs one turn against the API and appends the assistant response to the history automatically.

Optional auto-cache mode (set via Conversation::with_auto_cache or Conversation::with_cache_breakpoint_on_system) applies an ephemeral cache_control breakpoint to the system prompt and optionally the most recent user turn before each request, so cache hits stay high without the app needing to think about it.

Conversation is Serialize + Deserialize, so a session can be persisted to disk and resumed later.

Gated on the conversation feature.

Structs§

ContextCompactionPolicy
Policy controlling when and how Conversation drops older turns to stay under a token budget.
Conversation
Multi-turn conversation state plus per-request defaults.
UsageRecord
One turn’s Usage paired with the model it ran on.

Enums§

AutoCacheMode
Automatic cache-breakpoint placement for outgoing requests.