Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }
Expand description

High-level semantic agent handle for one session.

Clones share the same runtime-owned session. The runtime admits one active run or direct mutation per session at a time.

Implementations§

Source§

impl Agent

Source

pub fn session_handle(&self) -> CodingSessionHandle

Returns a cloneable inspection and control handle for this agent’s session.

Source

pub fn active_permission_grants(&self) -> ActivePermissionGrants

Returns a point-in-time snapshot of active session-scoped permission grants and user-authored review guidance notes.

Source

pub fn revoke_session_grant( &self, id: SessionGrantId, ) -> Result<bool, ProcessRunnerError>

Revokes one active session-scoped permission grant by its stable ID.

Source

pub fn clear_session_grants(&self) -> Result<(), ProcessRunnerError>

Clears all active session-scoped permission grants immediately.

Source

pub fn revoke_review_guidance(&self, id: ReviewGuidanceId) -> bool

Revokes one session-scoped human review guidance note by its stable ID.

Source

pub fn session_id(&self) -> &SessionId

Returns the session identity owned by this agent.

Source

pub fn loop_config(&self) -> &AgentLoopConfig

Returns the configured bounded loop policy.

Source

pub fn profile(&self) -> Option<&dyn AgentProfile>

Returns the configured application-level profile when one was installed.

Source

pub async fn run(&self, task: &str) -> Result<RunResult, AgentError>

Runs one task to a terminal, blocked, failed, or cancelled result.

Source

pub async fn run_structured<T>( &self, task: &str, ) -> Result<StructuredRunResult<T>, AgentError>

Runs one task and decodes its runtime-recorded final output as T.

T must produce an object-shaped JSON Schema. Merry validates that contract before starting the model loop; scalar and array output types return AgentError::FinalOutputContract immediately.

Source

pub fn stream(&self, task: &str) -> Result<AgentEventStream, AgentError>

Starts an event-only stream for one non-interactive task.

Registered Rust tools are executed by runtime and are therefore not exposed as invocation messages. A host that deliberately owns tool callables can use Self::stream_with_tool_handoff instead.

Source

pub fn stream_with_owned_tool_handoff( &self, task: &str, ) -> Result<OwnedAgentRun, AgentError>

Starts an owned host-tool handoff stream for a foreign-language binding.

The returned handle keeps the same message-first and batch-resolution contract as Self::stream_with_tool_handoff without exposing Rust borrow lifetimes to the binding layer.

Source

pub fn stream_with_owned_tool_handoff_and_schema( &self, task: &str, schema: ToolInputSchema, ) -> Result<OwnedAgentRun, AgentError>

Starts an owned host-tool handoff stream with a runtime-owned final structured-output contract.

Source

pub fn stream_structured<T>( &self, task: &str, ) -> Result<StructuredAgentEventStream<T>, AgentError>

Starts a live stream whose terminal result is decoded as T.

T must produce an object-shaped JSON Schema. The schema is compiled before the provider is called, so an unsupported shape is reported at stream construction time.

Source

pub fn start_interactive(&self) -> Result<InteractiveRun, AgentError>

Starts an interactive run with the same runtime event and loop contracts.

Source

pub fn start_interactive_owned(&self) -> Result<OwnedInteractiveRun, AgentError>

Starts an owned interactive run for foreign-language bindings.

Source

pub async fn compact( &self, focus: Option<String>, policy: Option<CitationCompactionPolicy>, ) -> Result<Option<CompactionOutcome>, AgentError>

Manually compacts session history outside an active run, optionally emphasizing focus instructions and overriding the configured CitationCompactionPolicy for this call.

Returns Ok(None) when no compressible history exists before the retained tail.

Source

pub async fn save_session(&self) -> Result<(), AgentError>

Saves the current resume-safe session state to its configured store.

Source

pub async fn save_session_to( &self, store: FileSessionStore, ) -> Result<(), AgentError>

Saves the current resume-safe session state to an explicit store.

Source

pub fn trajectory_handle(&self) -> TrajectoryHandle

Returns a read-only trajectory observability handle for this session.

Source

pub fn is_closed(&self) -> bool

Returns whether Self::close has closed this agent session.

Source

pub async fn close(&self) -> Result<(), AgentError>

Closes this agent session, releasing any held OS-level session lock and removing an untouched empty session directory.

Closing is idempotent once completed. Subsequent operations on the closed agent fail with merry_runtime::RuntimeError::SessionClosed.

Trait Implementations§

Source§

impl Clone for Agent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<CodingSession> for Agent

Source§

fn from(session: CodingSession) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Agent

§

impl !UnwindSafe for Agent

§

impl Forget for Agent

§

impl Freeze for Agent
where *const ArcInner<RuntimeInner> is !null: Freeze, PhantomData<ArcInner<RuntimeInner>>: Freeze, NonZero<usize>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Value>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, *const ArcInner<Validator> is !null: Freeze, PhantomData<ArcInner<Validator>>: Freeze, *const ArcInner<dyn Fn(&str) -> Result<(), String> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn Fn(&str) -> Result<(), String> + Sync + Send>>: Freeze, *const ArcInner<dyn AgentProfile> is !null: Freeze, PhantomData<ArcInner<dyn AgentProfile>>: Freeze,

§

impl Move for Agent

§

impl Send for Agent
where Arc<RuntimeInner>: Send, NonZero<usize>: Send, RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, Arc<Validator>: Send, Arc<dyn Fn(&str) -> Result<(), String> + Sync + Send>: Send, Arc<dyn AgentProfile>: Send,

§

impl Sync for Agent
where Arc<RuntimeInner>: Sync, NonZero<usize>: Sync, RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync, Arc<Validator>: Sync, Arc<dyn Fn(&str) -> Result<(), String> + Sync + Send>: Sync, Arc<dyn AgentProfile>: Sync,

§

impl Unpin for Agent
where Arc<RuntimeInner>: Unpin, NonZero<usize>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, Arc<Validator>: Unpin, Arc<dyn Fn(&str) -> Result<(), String> + Sync + Send>: Unpin, Arc<dyn AgentProfile>: Unpin,

§

impl UnsafeUnpin for Agent
where *const ArcInner<RuntimeInner> is !null: UnsafeUnpin, PhantomData<ArcInner<RuntimeInner>>: UnsafeUnpin, NonZeroUsizeInner: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Value>: UnsafeUnpin, *const LeafNode<String, Value> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, Value)>>: UnsafeUnpin, *const ArcInner<Validator> is !null: UnsafeUnpin, PhantomData<ArcInner<Validator>>: UnsafeUnpin, *const ArcInner<dyn Fn(&str) -> Result<(), String> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn(&str) -> Result<(), String> + Sync + Send>>: UnsafeUnpin, *const ArcInner<dyn AgentProfile> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn AgentProfile>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<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