Skip to main content

SelfHandler

Trait SelfHandler 

Source
pub trait SelfHandler {
    // Required methods
    fn tools(&self) -> Vec<ToolDef>;
    fn handle(&mut self, name: &str, args: &Value) -> Option<(String, bool)>;

    // Provided methods
    fn read_resource(&mut self, _uri: &str) -> Option<(String, bool)> { ... }
    fn serves_self_resources(&self) -> bool { ... }
    fn take_scheduled(&mut self) -> Vec<ScheduleRequest> { ... }
    fn take_subscriptions(&mut self) -> Vec<SubscriptionRequest> { ... }
}
Expand description

Provides agentd’s in-process self-tools to the loop. The loop tries the self-handler first; a None result means “not a self-tool — fall through to MCP”.

Required Methods§

Source

fn tools(&self) -> Vec<ToolDef>

The self-tool definitions to advertise to the model (added to the MCP catalogue).

Source

fn handle(&mut self, name: &str, args: &Value) -> Option<(String, bool)>

Handle a tool call. Returns Some((observation, is_error)) if name is one of this handler’s self-tools; None to fall through to MCP.

Provided Methods§

Source

fn read_resource(&mut self, _uri: &str) -> Option<(String, bool)>

Read an agentd:// self-resource (e.g. agentd://subagent/<handle> — an async child’s completion). A resource.read for an agentd:// URI routes here instead of to MCP. Returns Some((content, is_error)) if this handler serves the URI; None (the default) means it does not, and the read falls through to MCP.

Source

fn serves_self_resources(&self) -> bool

Whether this handler exposes any agentd:// self-resources — so the loop offers the resource.read tool even when no MCP resources exist. Default false.

Source

fn take_scheduled(&mut self) -> Vec<ScheduleRequest>

Drain any future wake-ups the agent scheduled for itself this run. Default: none. The loop attaches these to the run’s Outcome so a daemon supervisor can arm them.

Source

fn take_subscriptions(&mut self) -> Vec<SubscriptionRequest>

Drain any resource (un)subscriptions the agent requested for itself this run. Default: none. Attached to the run’s Outcome.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§