pub struct AgentConfig { /* private fields */ }Expand description
Portable agent-wide runtime configuration.
Workspace model, reasoning-effort, and knowledge defaults belong to
crate::workspace::WorkspaceDefaults, not this type.
§Examples
use std::num::NonZeroUsize;
use std::time::Duration;
use agents_kit::{
config::{AgentConfig, CodexConfig},
KitError,
};
let agent_config = || -> Result<AgentConfig, KitError> {
let backend = CodexConfig::spawn(
Duration::from_secs(15),
Duration::from_secs(60),
)?;
AgentConfig::new(
backend.into(),
Duration::from_secs(60),
NonZeroUsize::new(1).expect("one is nonzero"),
)?
.with_display_name("documentation-agent")
};
let config = agent_config()?;
assert_eq!(config.display_name(), Some("documentation-agent"));Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn new(
backend: BackendConfig,
lifecycle_timeout: Duration,
prompt_limit: NonZeroUsize,
) -> Result<Self, KitError>
pub fn new( backend: BackendConfig, lifecycle_timeout: Duration, prompt_limit: NonZeroUsize, ) -> Result<Self, KitError>
Creates agent-wide configuration with tracing disabled and no optional text.
§Errors
Returns crate::error::ErrorKind::InvalidConfig when the lifecycle timeout is zero or the selected backend configuration is invalid.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.lifecycle_timeout(), Duration::from_secs(30));
assert_eq!(config.prompt_limit().get(), 1);Sourcepub fn with_display_name(
self,
display_name: impl Into<String>,
) -> Result<Self, KitError>
pub fn with_display_name( self, display_name: impl Into<String>, ) -> Result<Self, KitError>
Sets a nonempty, unpadded display name.
§Errors
Returns crate::error::ErrorKind::InvalidConfig for an empty or padded display name.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
let config = config.with_display_name("worker")?;
assert_eq!(config.display_name(), Some("worker"));Sourcepub fn with_instructions(
self,
instructions: impl Into<String>,
) -> Result<Self, KitError>
pub fn with_instructions( self, instructions: impl Into<String>, ) -> Result<Self, KitError>
Sets nonempty, unpadded agent-level instructions.
§Errors
Returns crate::error::ErrorKind::InvalidConfig for empty or padded instructions.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
let config = config.with_instructions("Use concise answers.")?;
assert_eq!(config.instructions(), Some("Use concise answers."));Sourcepub fn with_tracing_enabled(self, tracing_enabled: bool) -> Self
pub fn with_tracing_enabled(self, tracing_enabled: bool) -> Self
Enables or disables runtime tracing for this agent.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
let config = config.with_tracing_enabled(true);
assert!(config.tracing_enabled());Sourcepub fn with_default_prompt_timeout(
self,
timeout: Duration,
) -> Result<Self, KitError>
pub fn with_default_prompt_timeout( self, timeout: Duration, ) -> Result<Self, KitError>
Sets the default foreground prompt timeout used when a request omits one.
§Errors
Returns crate::error::ErrorKind::InvalidConfig when the timeout is zero.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
let config = config.with_default_prompt_timeout(Duration::from_secs(45))?;
assert_eq!(config.default_prompt_timeout(), Some(Duration::from_secs(45)));Sourcepub fn backend(&self) -> &BackendConfig
pub fn backend(&self) -> &BackendConfig
Returns the selected backend configuration.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert!(matches!(config.backend(), agents_kit::config::BackendConfig::Codex(_)));Sourcepub fn display_name(&self) -> Option<&str>
pub fn display_name(&self) -> Option<&str>
Returns the configured display name, when present.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.display_name(), None);Sourcepub fn instructions(&self) -> Option<&str>
pub fn instructions(&self) -> Option<&str>
Returns the configured agent-level instructions, when present.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.instructions(), None);Sourcepub fn tracing_enabled(&self) -> bool
pub fn tracing_enabled(&self) -> bool
Returns whether runtime tracing is enabled.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert!(!config.tracing_enabled());Sourcepub fn lifecycle_timeout(&self) -> Duration
pub fn lifecycle_timeout(&self) -> Duration
Returns the bound used for agent lifecycle and recovery work.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.lifecycle_timeout(), Duration::from_secs(30));Sourcepub fn prompt_limit(&self) -> NonZeroUsize
pub fn prompt_limit(&self) -> NonZeroUsize
Returns the maximum number of concurrently admitted prompts for the agent.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.prompt_limit().get(), 1);Sourcepub fn default_prompt_timeout(&self) -> Option<Duration>
pub fn default_prompt_timeout(&self) -> Option<Duration>
Returns the default foreground prompt timeout, when configured.
use agents_kit::config::{AgentConfig, CodexConfig};
use std::{num::NonZeroUsize, time::Duration};
let config = AgentConfig::new(CodexConfig::spawn(Duration::from_secs(15),
Duration::from_secs(60))?.into(), Duration::from_secs(30), NonZeroUsize::MIN)?;
assert_eq!(config.default_prompt_timeout(), None);Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Auto Trait Implementations§
impl Freeze for AgentConfig
impl RefUnwindSafe for AgentConfig
impl Send for AgentConfig
impl Sync for AgentConfig
impl Unpin for AgentConfig
impl UnsafeUnpin for AgentConfig
impl UnwindSafe for AgentConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.