Skip to main content

AgentBase

Struct AgentBase 

Source
pub struct AgentBase {
Show 24 fields pub upstream: Upstream, pub model: String, pub output_mode: OutputMode, pub synthetic_reasoning: Option<bool>, pub top_logprobs: Option<u64>, pub prefix_messages: Option<Vec<Message>>, pub post_system_prefix_messages: Option<Vec<Message>>, pub suffix_messages: Option<Vec<Message>>, pub mcp_servers: Option<McpServers>, pub frequency_penalty: Option<f64>, pub logit_bias: Option<IndexMap<String, i64>>, pub max_completion_tokens: Option<u64>, pub presence_penalty: Option<f64>, pub stop: Option<Stop>, pub temperature: Option<f64>, pub top_p: Option<f64>, pub max_tokens: Option<u64>, pub min_p: Option<f64>, pub provider: Option<Provider>, pub reasoning: Option<Reasoning>, pub repetition_penalty: Option<f64>, pub top_a: Option<f64>, pub top_k: Option<u64>, pub verbosity: Option<Verbosity>,
}
Expand description

The base configuration for an OpenRouter Agent (without computed ID).

Fields§

§upstream: Upstream

The upstream provider marker.

§model: String

The upstream language model identifier (e.g., "gpt-4", "claude-3-opus").

§output_mode: OutputMode

The output mode for vector completions. Ignored for agent completions.

§synthetic_reasoning: Option<bool>

Enable synthetic reasoning for non-reasoning LLMs.

Vector completions only. Ignored for agent completions.

§top_logprobs: Option<u64>

Number of top log probabilities to return (2-20).

Vector completions only. Ignored for agent completions.

§prefix_messages: Option<Vec<Message>>

Messages prepended to the user’s prompt.

§post_system_prefix_messages: Option<Vec<Message>>

Messages inserted after the leading chain of system/developer messages.

§suffix_messages: Option<Vec<Message>>

Messages appended after the user’s prompt.

§mcp_servers: Option<McpServers>

MCP servers the agent can connect to.

§frequency_penalty: Option<f64>

Penalizes tokens based on their frequency in the output so far (-2.0 to 2.0).

§logit_bias: Option<IndexMap<String, i64>>

Token ID to bias mapping (-100 to 100). Positive values increase likelihood.

§max_completion_tokens: Option<u64>

Maximum tokens in the completion.

§presence_penalty: Option<f64>

Penalizes tokens based on their presence in the output so far (-2.0 to 2.0).

§stop: Option<Stop>

Stop sequences that halt generation.

§temperature: Option<f64>

Sampling temperature (0.0 to 2.0). Higher = more random.

§top_p: Option<f64>

Nucleus sampling probability (0.0 to 1.0).

§max_tokens: Option<u64>

Maximum tokens (OpenRouter variant of max_completion_tokens).

§min_p: Option<f64>

Minimum probability threshold for sampling (0.0 to 1.0).

§provider: Option<Provider>

Provider routing preferences.

§reasoning: Option<Reasoning>

Reasoning/thinking configuration for supported models.

§repetition_penalty: Option<f64>

Repetition penalty (0.0 to 2.0). Values > 1.0 penalize repetition.

§top_a: Option<f64>

Top-a sampling parameter (0.0 to 1.0).

§top_k: Option<u64>

Top-k sampling: only consider the k most likely tokens.

§verbosity: Option<Verbosity>

Output verbosity hint for supported models.

Implementations§

Source§

impl AgentBase

Source

pub fn prepare(&mut self)

Normalizes the configuration for deterministic ID computation.

Source

pub fn validate(&self) -> Result<(), String>

Validates the configuration.

Source

pub fn merged_messages(&self, messages: Vec<Message>) -> Vec<Message>

Returns prefix messages, then the provided messages, then suffix messages.

Source

pub fn id(&self) -> String

Computes the deterministic content-addressed ID.

Trait Implementations§

Source§

impl<'arbitrary> Arbitrary<'arbitrary> for AgentBase

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for AgentBase

Source§

fn clone(&self) -> AgentBase

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 AgentBase

Source§

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

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

impl Default for AgentBase

Source§

fn default() -> AgentBase

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AgentBase

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for AgentBase

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for AgentBase

Source§

fn eq(&self, other: &AgentBase) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AgentBase

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<AgentBase> for Agent

Source§

type Error = String

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

fn try_from(base: AgentBase) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for AgentBase

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

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

Source§

impl<T> ToJmespath for T
where T: Serialize,

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 = 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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,