Skip to main content

Options

Struct Options 

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

Settings for an AgentCat handle. Options::default turns on the context parameter, tracing and the get_more_tools tool, and turns off agent tracking; each setter consumes the options and returns them changed.

use agentcat_sdk::Options;

let options = Options::default()
    .enable_agent_tracking(true)
    .custom_context_description("Say why you call this tool.");

The four hooks (resolve_session_id, identify, event_tags, event_properties) are async closures over a ToolCall. The SDK starts them on the tokio runtime that serves the call and never waits for them, so a slow hook cannot delay a tool call. A hook that returns an error or None gives nothing. rmcp’s local feature is not supported, because hooks run as Send tasks.

Implementations§

Source§

impl Options

Source

pub fn resolve_session_id<F, Fut>(self, hook: F) -> Self
where F: Fn(ToolCall) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<String>, HookError>> + Send + 'static,

Decides the session of each tool call (hook mode). With this hook set, tools get no session_id parameter and the SDK mints nothing back to the agent. The hook returns the session id, or None to let the SDK mint one.

Source

pub fn identify<F, Fut>(self, hook: F) -> Self
where F: Fn(ToolCall) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<UserIdentity>, HookError>> + Send + 'static,

Says who made each tool call. The hook runs on every call; None leaves the call anonymous.

Source

pub fn event_tags<F, Fut>(self, hook: F) -> Self
where F: Fn(ToolCall) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<Map<String, Value>>, HookError>> + Send + 'static,

Adds the returned tags to the event of each tool call.

Source

pub fn event_properties<F, Fut>(self, hook: F) -> Self
where F: Fn(ToolCall) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<Map<String, Value>>, HookError>> + Send + 'static,

Adds the returned properties to the event of each tool call.

Source

pub fn api_base_url(self, url: impl Into<String>) -> Self

The base URL of the AgentCat API, in place of the environment’s and the default. An empty text means none is set. The URL is used as given.

Source

pub fn redact_sensitive_information<F, Fut>(self, hook: F) -> Self
where F: Fn(String) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<String, HookError>> + Send + 'static,

Redacts every string of each event before it leaves the process: the hook gets one string at a time and returns the string to send. It runs on the tokio runtime that serves the call. When it fails, the SDK drops the event rather than send it unredacted.

The SDK gives the hook no time limit. An event holds one of the 5 delivery slots of its handle while the hook runs on it. A hook that never completes holds its slot for good, and five such hooks stop the delivery of the handle: later events wait in the queue until a shutdown abandons them.

Source

pub fn redact_event<F, Fut>(self, hook: F) -> Self
where F: Fn(Event) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<Option<Event>, HookError>> + Send + 'static,

Changes each event before it leaves the process: the hook gets the whole Event and returns the event to send, or Ok(None) to drop it. It runs on the tokio runtime that serves the call. When it fails, the SDK drops the event. To unit-test the hook, call it with an event from Event::default.

The SDK gives the hook no time limit. An event holds one of the 5 delivery slots of its handle while the hook runs on it. A hook that never completes holds its slot for good, and five such hooks stop the delivery of the handle: later events wait in the queue until a shutdown abandons them.

Source

pub fn log_destination(self, destination: LogDestination) -> Self

Where the SDK writes its own log lines. The first handle built in the process decides. The default is LogDestination::File.

Source

pub fn enable_report_missing(self, on: bool) -> Self

Whether tool listings get the get_more_tools tool, through which agents report a tool they miss.

Source

pub fn enable_tracing(self, on: bool) -> Self

Whether tool calls are recorded and tools get the session_id parameter. With tracing off, tools get neither session_id nor agent_id (also with agent tracking on), and nothing is recorded; tools still get the context parameter and get_more_tools. Each call goes to the tool without the parameters the SDK added to it, as with tracing on, so a tool that declares its own context keeps it.

Source

pub fn enable_tool_call_context(self, on: bool) -> Self

Whether tools get a required context parameter, in which agents say why they call the tool. The text is recorded as the intent of the call.

Source

pub fn enable_agent_tracking(self, on: bool) -> Self

Whether tools get a required agent_id parameter, with which agents identify themselves. Only with tracing on (enable_tracing).

Source

pub fn custom_context_description(self, text: impl Into<String>) -> Self

The description of the context parameter that agents read. An empty text means the default description.

Trait Implementations§

Source§

impl Clone for Options

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 Debug for Options

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Options

Source§

fn default() -> Self

The defaults: missing-tool reports on, tracing on, the context parameter on, agent tracking off, and the default context description.

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

Source§

type Output = T

Should always be Self
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