pub struct UsageLimits {
pub request_limit: Option<u64>,
pub input_tokens_limit: Option<u64>,
pub output_tokens_limit: Option<u64>,
pub total_tokens_limit: Option<u64>,
pub tool_calls_limit: Option<u64>,
}Expand description
Runtime usage limits for one agent run.
Fields§
§request_limit: Option<u64>Maximum provider requests allowed in one run.
input_tokens_limit: Option<u64>Maximum input tokens allowed.
output_tokens_limit: Option<u64>Maximum output tokens allowed.
total_tokens_limit: Option<u64>Maximum total tokens allowed.
tool_calls_limit: Option<u64>Maximum successful function tool calls allowed.
Implementations§
Source§impl UsageLimits
impl UsageLimits
Sourcepub const fn with_request_limit(self, limit: u64) -> Self
pub const fn with_request_limit(self, limit: u64) -> Self
Set request limit.
Sourcepub const fn with_input_tokens_limit(self, limit: u64) -> Self
pub const fn with_input_tokens_limit(self, limit: u64) -> Self
Set input token limit.
Sourcepub const fn with_output_tokens_limit(self, limit: u64) -> Self
pub const fn with_output_tokens_limit(self, limit: u64) -> Self
Set output token limit.
Sourcepub const fn with_total_tokens_limit(self, limit: u64) -> Self
pub const fn with_total_tokens_limit(self, limit: u64) -> Self
Set total token limit.
Sourcepub const fn with_tool_calls_limit(self, limit: u64) -> Self
pub const fn with_tool_calls_limit(self, limit: u64) -> Self
Set successful tool-call limit.
Sourcepub const fn check_before_request(
&self,
current: &Usage,
) -> Result<(), UsageLimitError>
pub const fn check_before_request( &self, current: &Usage, ) -> Result<(), UsageLimitError>
Check whether the next model request would exceed the request limit.
§Errors
Returns an error when another request would exceed the configured request limit.
Sourcepub const fn check_tool_calls(
&self,
projected: &Usage,
) -> Result<(), UsageLimitError>
pub const fn check_tool_calls( &self, projected: &Usage, ) -> Result<(), UsageLimitError>
Check whether projected tool calls would exceed the tool-call limit.
§Errors
Returns an error when executing the next successful tool calls would exceed the configured limit.
Sourcepub fn check_usage(&self, usage: &Usage) -> Result<(), UsageLimitError>
pub fn check_usage(&self, usage: &Usage) -> Result<(), UsageLimitError>
Check whether accumulated usage exceeds configured token or pricing limits.
§Errors
Returns an error when accumulated usage exceeds any configured limit.
Trait Implementations§
Source§impl Clone for UsageLimits
impl Clone for UsageLimits
Source§fn clone(&self) -> UsageLimits
fn clone(&self) -> UsageLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UsageLimits
impl Debug for UsageLimits
Source§impl Default for UsageLimits
impl Default for UsageLimits
Source§fn default() -> UsageLimits
fn default() -> UsageLimits
Source§impl<'de> Deserialize<'de> for UsageLimits
impl<'de> Deserialize<'de> for UsageLimits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for UsageLimits
Source§impl PartialEq for UsageLimits
impl PartialEq for UsageLimits
Source§fn eq(&self, other: &UsageLimits) -> bool
fn eq(&self, other: &UsageLimits) -> bool
self and other values to be equal, and is used by ==.