Skip to main content

Agent

Struct Agent 

Source
pub struct Agent {
Show 30 fields pub model: Model, pub thinking_level: ThinkingLevel, pub tools: ToolRegistry, pub messages: Vec<Message>, pub system_prompt: String, pub cwd: PathBuf, pub max_turns: u32, pub max_tokens: Option<u32>, pub role: Option<Role>, pub hooks: HookRunner, pub api_key: String, pub auth_store: Option<Arc<Mutex<AuthStore>>>, pub ui: Arc<dyn UserInterface>, pub context_config: ContextConfig, pub retry_policy: RetryPolicy, pub mode: AgentMode, pub has_mana_skill: bool, pub has_mana_basics_skill: bool, pub has_mana_delegation_skill: bool, pub guardrail_config: GuardrailConfig, pub guardrail_profile: Option<GuardrailProfile>, pub lua_tool_loader: Option<LuaToolLoader>, pub file_cache: Arc<FileCache>, pub checkpoint_state: Arc<CheckpointState>, pub file_tracker: Arc<Mutex<FileTracker>>, pub anchor_store: Arc<AnchorStore>, pub read_max_lines: usize, pub cache_options: CacheOptions, pub continue_policy: ContinuePolicy, pub config: Arc<Config>, /* private fields */
}
Expand description

The core agent — runs the ReAct loop (reason, act, observe).

Fields§

§model: Model§thinking_level: ThinkingLevel§tools: ToolRegistry§messages: Vec<Message>§system_prompt: String§cwd: PathBuf§max_turns: u32§max_tokens: Option<u32>§role: Option<Role>§hooks: HookRunner§api_key: String§auth_store: Option<Arc<Mutex<AuthStore>>>

Optional auth store for automatic OAuth token refresh before LLM calls. Optional auth store for automatic OAuth token refresh before LLM calls.

§ui: Arc<dyn UserInterface>§context_config: ContextConfig

Context management thresholds (wired from Config via AgentBuilder).

§retry_policy: RetryPolicy

Retry policy for transient LLM stream failures.

§mode: AgentMode

Active agent mode — controls which tools are permitted.

§has_mana_skill: bool

Whether a mana skill is available in discovered resources.

§has_mana_basics_skill: bool

Whether a mana-basics skill is available in discovered resources.

§has_mana_delegation_skill: bool

Whether a mana-delegation skill is available in discovered resources.

§guardrail_config: GuardrailConfig

Engineering guardrails config.

§guardrail_profile: Option<GuardrailProfile>

Resolved guardrail profile (None = disabled).

§lua_tool_loader: Option<LuaToolLoader>

Cloneable Lua extension tool loader inherited from the session/builder.

§file_cache: Arc<FileCache>

In-session file content cache, shared across tool calls.

§checkpoint_state: Arc<CheckpointState>

Shared checkpoint/file-history state, used to capture destructive edit restore points.

§file_tracker: Arc<Mutex<FileTracker>>

Tracks which files have been read; used for staleness and unread-edit warnings.

§anchor_store: Arc<AnchorStore>

Session-local anchors emitted by read and consumed by anchored edit mode.

§read_max_lines: usize

Max lines the read tool may return before truncating. 0 means unlimited.

§cache_options: CacheOptions

Cache options for LLM requests.

§continue_policy: ContinuePolicy

Policy for imp-local visible auto-continuation after high-confidence turns.

§config: Arc<Config>

Resolved runtime config for tool-specific policy checks.

Implementations§

Source§

impl Agent

Source

pub fn new(model: Model, cwd: PathBuf) -> (Self, AgentHandle)

Source

pub async fn run(&mut self, prompt: String) -> Result<()>

Run the agent loop with an initial prompt.

Auto Trait Implementations§

§

impl Freeze for Agent

§

impl !RefUnwindSafe for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

§

impl !UnwindSafe for Agent

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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