Conversation & Chat History
AgentFlow stores each multi-turn thread as a conversation. A conversation contains the visible user/assistant chat history, execution metadata, tool and sub-agent events, attachments, artifacts, markers, and stream recovery state. Persistent cross-conversation personalization lives in Memory. This page covers conversation-local state only.Vocabulary
| Term | Meaning |
|---|---|
| Conversation | Durable thread metadata: id, title, agent, source, timestamps, and active-generation state |
| Chat history | Flat user/assistant messages returned by /messages and used by SDK detail() |
| Timeline | Full UI reconstruction, including tool calls, sub-agent calls, artifacts, approvals, and feedback |
| Conversation parts | Atomic persisted rows that rebuild chat history and timeline state |
| Chat-history compaction | Conversation-local summarization used when a long thread approaches the model context window |
| Memory | Persistent per-user or per-agent facts across conversations; see Memory |
Conversation Lifecycle
SDK users usually create or resume a conversation handle, then send messages through it:conversation_id and message_id values when chatting so retries can be de-duplicated:
Reading Conversations
/messages is intentionally flat and user-facing. /timeline is richer and reconstructs the execution tree for product UI.
Conversation Parts
Conversation parts are the durable source of truth. They are ordered byseq and linked by call_id, parent_call_id, and root_call_id.
| Stored part type | Public role/view | Source |
|---|---|---|
user | user message | User chat request or manual message append |
agent_text | assistant message | Streamed assistant text |
tool_request | Timeline event | LLM tool call |
tool_response | Timeline event | Tool result |
sub_agent_request | Timeline event | Delegation to a sub-agent |
sub_agent_response | Timeline event | Sub-agent result |
system_event | Hidden or timeline system event | Artifact summaries, artifact actions, compaction notices |
Timeline And Stream Recovery
Live chat streams are detached from browser lifetime. If a tab closes, the run continues in the background and clients can reconnect to the durable conversation stream:| Event | Purpose |
|---|---|
conversation_snapshot | Initial durable timeline snapshot |
conversation_update | Updated durable snapshot when parts, runs, markers, or feedback change |
conversation_stream_complete | Terminal marker once no active generation remains |
Chat-History Compaction
Long conversations can exceed model context windows. AgentFlow compacts conversation-local chat history by summarizing older turns while keeping recent turns intact. This is not persistent user memory. It is a per-conversation context-window optimization.| Setting | Default | Description |
|---|---|---|
max_conversation_messages | 50 | Trigger compaction when history exceeds this count |
target_conversation_messages | 30 | Target message count after compaction |
preserve_recent_turns | 10 | Always keep this many recent user turns |
Titles And Metadata
Titles are generated from early user messages and can be overwritten:source, source_id, source_metadata, last_read_at, has_active_generation, and message_count for list and sidebar workflows.
