pub struct AgentThread {Show 13 fields
pub id: ThreadId,
pub kind: ThreadKind,
pub label: String,
pub description: Option<String>,
pub status: ThreadStatus,
pub parent_id: Option<ThreadId>,
pub created_at: SystemTime,
pub last_activity: SystemTime,
pub is_foreground: bool,
pub messages: VecDeque<ThreadMessage>,
pub compact_summary: Option<String>,
pub result: Option<String>,
pub share_context: bool,
}Expand description
An agent thread — the unified representation of all concurrent work.
Fields§
§id: ThreadIdUnique identifier
kind: ThreadKindWhat kind of thread this is
label: StringUser-visible label
description: Option<String>Agent-settable description of current activity
status: ThreadStatusCurrent status
parent_id: Option<ThreadId>Parent thread that spawned this (if any)
created_at: SystemTimeWhen the thread was created
last_activity: SystemTimeWhen the thread last had activity
is_foreground: boolIs this the foreground (user-focused) thread?
messages: VecDeque<ThreadMessage>Conversation history (for interactive threads)
compact_summary: Option<String>Compacted summary of older messages
result: Option<String>Result value (for task/sub-agent threads)
Should this thread’s context be shared with parent?
Implementations§
Source§impl AgentThread
impl AgentThread
Sourcepub fn new_subagent(
label: impl Into<String>,
agent_id: impl Into<String>,
task: impl Into<String>,
parent_id: Option<ThreadId>,
) -> Self
pub fn new_subagent( label: impl Into<String>, agent_id: impl Into<String>, task: impl Into<String>, parent_id: Option<ThreadId>, ) -> Self
Create a new sub-agent thread.
Sourcepub fn new_background(
label: impl Into<String>,
purpose: impl Into<String>,
parent_id: Option<ThreadId>,
) -> Self
pub fn new_background( label: impl Into<String>, purpose: impl Into<String>, parent_id: Option<ThreadId>, ) -> Self
Create a new background thread.
Sourcepub fn new_task(
label: impl Into<String>,
action: impl Into<String>,
parent_id: Option<ThreadId>,
) -> Self
pub fn new_task( label: impl Into<String>, action: impl Into<String>, parent_id: Option<ThreadId>, ) -> Self
Create a new task thread.
Sourcepub fn set_description(&mut self, description: impl Into<String>)
pub fn set_description(&mut self, description: impl Into<String>)
Update the description.
Sourcepub fn set_status(&mut self, status: ThreadStatus)
pub fn set_status(&mut self, status: ThreadStatus)
Update the status.
Sourcepub fn complete(&mut self, summary: Option<String>, result: Option<String>)
pub fn complete(&mut self, summary: Option<String>, result: Option<String>)
Mark as completed with optional result.
Sourcepub fn add_message(&mut self, role: MessageRole, content: impl Into<String>)
pub fn add_message(&mut self, role: MessageRole, content: impl Into<String>)
Add a message to the conversation history.
Sourcepub fn message_count(&self) -> usize
pub fn message_count(&self) -> usize
Get message count.
Sourcepub fn compaction_prompt(&self) -> String
pub fn compaction_prompt(&self) -> String
Generate a prompt for compacting this thread’s conversation.
Sourcepub fn apply_compaction(&mut self, summary: String)
pub fn apply_compaction(&mut self, summary: String)
Apply a compaction summary, keeping only recent messages.
Sourcepub fn build_context(&self) -> String
pub fn build_context(&self) -> String
Build context string for this thread (for system prompt injection).
Sourcepub fn to_info(&self) -> ThreadInfo
pub fn to_info(&self) -> ThreadInfo
Get info for sidebar display.
Trait Implementations§
Source§impl Clone for AgentThread
impl Clone for AgentThread
Source§fn clone(&self) -> AgentThread
fn clone(&self) -> AgentThread
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more