pub struct ThreadContext {
pub thread_ref: String,
pub platform: String,
pub platform_metadata: HashMap<String, String>,
pub participants: HashMap<String, Participant>,
pub current_view: Option<ChannelViewContext>,
}Expand description
Thread-level context for multi-user conversations.
A ThreadContext is created when a session is bound to a platform thread and accumulates participants as messages arrive. Platform adapters update this when new users join a thread.
Fields§
§thread_ref: StringPlatform-specific thread identifier (e.g. Slack thread_ts, Discord channel_id).
platform: StringSource platform (e.g. “slack”, “discord”, “teams”).
platform_metadata: HashMap<String, String>Platform-specific channel/workspace context.
participants: HashMap<String, Participant>Known participants in this thread, keyed by actor_id for O(1) lookup.
current_view: Option<ChannelViewContext>What the user is currently looking at on the platform, when it reports
that (Slack: app_context_changed). Last write wins — it is a current
position, not a history.
Implementations§
Source§impl ThreadContext
impl ThreadContext
Sourcepub fn new(thread_ref: impl Into<String>, platform: impl Into<String>) -> Self
pub fn new(thread_ref: impl Into<String>, platform: impl Into<String>) -> Self
Create a new thread context for a platform thread.
Sourcepub fn track_participant(&mut self, actor: &ExternalActor) -> bool
pub fn track_participant(&mut self, actor: &ExternalActor) -> bool
Record a participant. Updates first_seen_at only if new. Returns true if this is a newly seen participant.
Sourcepub fn participant_count(&self) -> usize
pub fn participant_count(&self) -> usize
Number of distinct participants.
Sourcepub fn participants_summary(&self) -> String
pub fn participants_summary(&self) -> String
Build a summary line for LLM context injection. e.g. “Thread participants: Alice, Bob, Charlie”
Sourcepub fn set_current_view(&mut self, view: ChannelViewContext) -> bool
pub fn set_current_view(&mut self, view: ChannelViewContext) -> bool
Record where the user is now looking. Last write wins.
Returns true when this actually changed the stored position, so callers can skip a write when the platform re-reports the same place.
Sourcepub fn view_summary(&self) -> String
pub fn view_summary(&self) -> String
One line describing where the user is looking, for model context.
Phrased as a hint the agent must ask about rather than a fact it can act on. The platform reports what the user is viewing, which the agent may have no access to and no tool for; stating it as available context would invite the model to claim knowledge of a channel it cannot read. The id stays opaque for the same reason — resolving it to a name would mean fetching a channel the agent was never granted.
Trait Implementations§
Source§impl Clone for ThreadContext
impl Clone for ThreadContext
Source§fn clone(&self) -> ThreadContext
fn clone(&self) -> ThreadContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more