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
impl Agent
Sourcepub fn session_handle(&self) -> CodingSessionHandle
pub fn session_handle(&self) -> CodingSessionHandle
Returns a cloneable inspection and control handle for this agent’s session.
Sourcepub fn active_permission_grants(&self) -> ActivePermissionGrants
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.
Sourcepub fn revoke_session_grant(
&self,
id: SessionGrantId,
) -> Result<bool, ProcessRunnerError>
pub fn revoke_session_grant( &self, id: SessionGrantId, ) -> Result<bool, ProcessRunnerError>
Revokes one active session-scoped permission grant by its stable ID.
Sourcepub fn clear_session_grants(&self) -> Result<(), ProcessRunnerError>
pub fn clear_session_grants(&self) -> Result<(), ProcessRunnerError>
Clears all active session-scoped permission grants immediately.
Sourcepub fn revoke_review_guidance(&self, id: ReviewGuidanceId) -> bool
pub fn revoke_review_guidance(&self, id: ReviewGuidanceId) -> bool
Revokes one session-scoped human review guidance note by its stable ID.
Sourcepub fn session_id(&self) -> &SessionId
pub fn session_id(&self) -> &SessionId
Returns the session identity owned by this agent.
Sourcepub fn loop_config(&self) -> &AgentLoopConfig
pub fn loop_config(&self) -> &AgentLoopConfig
Returns the configured bounded loop policy.
Sourcepub fn profile(&self) -> Option<&dyn AgentProfile>
pub fn profile(&self) -> Option<&dyn AgentProfile>
Returns the configured application-level profile when one was installed.
Sourcepub async fn run(&self, task: &str) -> Result<RunResult, AgentError>
pub async fn run(&self, task: &str) -> Result<RunResult, AgentError>
Runs one task to a terminal, blocked, failed, or cancelled result.
Sourcepub async fn run_structured<T>(
&self,
task: &str,
) -> Result<StructuredRunResult<T>, AgentError>where
T: DeserializeOwned + JsonSchema,
pub async fn run_structured<T>(
&self,
task: &str,
) -> Result<StructuredRunResult<T>, AgentError>where
T: DeserializeOwned + JsonSchema,
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.
Sourcepub fn stream(&self, task: &str) -> Result<AgentEventStream, AgentError>
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.
Sourcepub fn stream_with_owned_tool_handoff(
&self,
task: &str,
) -> Result<OwnedAgentRun, AgentError>
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.
Sourcepub fn stream_with_owned_tool_handoff_and_schema(
&self,
task: &str,
schema: ToolInputSchema,
) -> Result<OwnedAgentRun, AgentError>
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.
Sourcepub fn stream_structured<T>(
&self,
task: &str,
) -> Result<StructuredAgentEventStream<T>, AgentError>where
T: DeserializeOwned + JsonSchema,
pub fn stream_structured<T>(
&self,
task: &str,
) -> Result<StructuredAgentEventStream<T>, AgentError>where
T: DeserializeOwned + JsonSchema,
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.
Sourcepub fn start_interactive(&self) -> Result<InteractiveRun, AgentError>
pub fn start_interactive(&self) -> Result<InteractiveRun, AgentError>
Starts an interactive run with the same runtime event and loop contracts.
Sourcepub fn start_interactive_owned(&self) -> Result<OwnedInteractiveRun, AgentError>
pub fn start_interactive_owned(&self) -> Result<OwnedInteractiveRun, AgentError>
Starts an owned interactive run for foreign-language bindings.
Sourcepub async fn compact(
&self,
focus: Option<String>,
policy: Option<CitationCompactionPolicy>,
) -> Result<Option<CompactionOutcome>, AgentError>
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.
Sourcepub async fn save_session(&self) -> Result<(), AgentError>
pub async fn save_session(&self) -> Result<(), AgentError>
Saves the current resume-safe session state to its configured store.
Sourcepub async fn save_session_to(
&self,
store: FileSessionStore,
) -> Result<(), AgentError>
pub async fn save_session_to( &self, store: FileSessionStore, ) -> Result<(), AgentError>
Saves the current resume-safe session state to an explicit store.
Sourcepub fn trajectory_handle(&self) -> TrajectoryHandle
pub fn trajectory_handle(&self) -> TrajectoryHandle
Returns a read-only trajectory observability handle for this session.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether Self::close has closed this agent session.
Sourcepub async fn close(&self) -> Result<(), AgentError>
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.