Skip to main content

Module history

Module history 

Source
Expand description

Conversation-history context providers.

Upstream moved conversation history out of the thread/session entirely: it is now just another ContextProvider — a HistoryProvider — that prepends its stored messages ahead of a run (before_run) and records the run’s request + response messages after a successful run (after_run). InMemoryHistoryProvider is the in-process default; FileHistoryProvider persists to a JSON file on disk.

Agent and WorkflowAgent auto-attach a fresh InMemoryHistoryProvider (via ensure_history_provider) to any non-service-managed AgentSession that doesn’t already carry a history provider, so local multi-turn conversations keep accumulating history the way the old AgentThread message store used to.

Structs§

FileHistoryProvider
A HistoryProvider that persists to a JSON file on disk, loading any existing history from path on construction and rewriting the whole file after every successful run.
InMemoryHistoryProvider
In-memory HistoryProvider: keeps history in an Arc<Mutex<Vec<Message>>>, shared across clones.

Enums§

StoredHistory
What a provider’s stored history is, which decides which occurrence of it inside a replayed transcript is the one it actually holds.

Traits§

HistoryProvider
A ContextProvider that also manages conversation history.

Functions§

ensure_history_provider
Attach a fresh InMemoryHistoryProvider as the first context provider on session when it is not service-managed and does not already carry a history provider. A no-op for service-managed sessions (the service owns history server-side) and for sessions that already have one attached (detected via ContextProvider::is_history_provider).
filter_new_messages
Return the suffix of incoming that is not already present in existing, so replaying a conversation does not store — or resend — it twice.
filter_new_messages_from
filter_new_messages with an explicit StoredHistory shape.
inject_stored_history
Inject stored ahead of any context another provider has already added — unless the run’s own input already carries that stored run, which is exactly what a caller replaying its own transcript sends.
inject_stored_history_from
inject_stored_history for a provider whose stored history has a known StoredHistory shape — a retention-limited store holds a StoredHistory::Window.
new_run_messages
What a run adds to existing: the part of its input that is not a replay of already-stored history (see filter_new_messages), followed by every response message.
new_run_messages_from
new_run_messages for a provider whose stored history has a known StoredHistory shape — a retention-limited store holds a StoredHistory::Window.