Skip to main content

AgentLoopSharedState

Struct AgentLoopSharedState 

Source
pub struct AgentLoopSharedState {
Show 17 fields pub streaming_content: Arc<Mutex<String>>, pub streaming_reasoning_content: Arc<Mutex<String>>, pub pending_user_messages: Arc<Mutex<Vec<ChatMessage>>>, pub background_manager: Arc<BackgroundManager>, pub todo_manager: Arc<TodoManager>, pub display_messages: Arc<Mutex<Vec<ChatMessage>>>, pub context_messages: Arc<Mutex<Vec<ChatMessage>>>, pub estimated_context_tokens: Arc<Mutex<usize>>, pub invoked_skills: InvokedSkillsMap, pub session_id: String, pub derived_system_prompt: Arc<Mutex<Option<String>>>, pub tool_registry: Arc<ToolRegistry>, pub disabled_tools: Vec<String>, pub deferred_tools: Arc<Mutex<Vec<String>>>, pub session_loaded_deferred: Arc<Mutex<Vec<String>>>, pub tools_enabled: bool, pub sub_agent_metrics: Arc<Mutex<SubAgentMetrics>>,
}
Expand description

Agent loop 的共享状态(Arc 引用,跨线程共享)

Fields§

§streaming_content: Arc<Mutex<String>>

流式内容缓冲区(agent 写入,UI 读取)

§streaming_reasoning_content: Arc<Mutex<String>>

流式思考内容缓冲区(reasoning_content,agent 写入,UI 读取)

§pending_user_messages: Arc<Mutex<Vec<ChatMessage>>>

用户在 agent loop 期间追加的消息队列

§background_manager: Arc<BackgroundManager>

后台任务管理器(由内置 PreLlmRequest hook 通过 Arc 引用使用)

§todo_manager: Arc<TodoManager>

待办管理器

§display_messages: Arc<Mutex<Vec<ChatMessage>>>

Agent/Teammate → UI 显示通道(仅用于 UI 渲染,不作为 LLM context 数据源)

§context_messages: Arc<Mutex<Vec<ChatMessage>>>

Agent/Teammate → LLM context 同步通道(persist_new_messages 直接从此持久化)

§estimated_context_tokens: Arc<Mutex<usize>>

Agent 实际使用的上下文 token 估算值(agent 每轮更新,UI 读取显示)

§invoked_skills: InvokedSkillsMap

会话内已调用技能追踪(LoadSkill 执行时记录,auto_compact 后恢复)

§session_id: String

当前会话 ID(用于 auto_compact 写入 session 级 .transcripts/)

§derived_system_prompt: Arc<Mutex<Option<String>>>

子 Agent 共用 system_prompt(每轮构建后更新,供 AgentTool / TeammateTool 读取)

§tool_registry: Arc<ToolRegistry>

工具注册表(用于每轮动态获取可用工具)

§disabled_tools: Vec<String>

用户禁用的工具列表

§deferred_tools: Arc<Mutex<Vec<String>>>

延迟加载的工具列表(LoadTool 加载后才可用)

§session_loaded_deferred: Arc<Mutex<Vec<String>>>

本会话 LoadTool 已加载的 deferred 工具

§tools_enabled: bool

工具是否启用

§sub_agent_metrics: Arc<Mutex<SubAgentMetrics>>

子 Agent metrics 累加器(SubAgent/Teammate 的 LLM/tool 统计) Main agent loop 结束时读取并合并到 SessionMetrics

Trait Implementations§

Source§

impl Debug for AgentLoopSharedState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more