Skip to main content

AgentSpec

Struct AgentSpec 

Source
pub struct AgentSpec {
Show 15 fields pub id: String, pub model_id: String, pub system_prompt: String, pub max_rounds: usize, pub max_continuation_retries: usize, pub context_policy: Option<ContextWindowPolicy>, pub reasoning_effort: Option<ReasoningEffort>, pub plugin_ids: Vec<String>, pub active_hook_filter: HashSet<String>, pub allowed_tools: Option<Vec<String>>, pub excluded_tools: Option<Vec<String>>, pub endpoint: Option<RemoteEndpoint>, pub delegates: Vec<String>, pub sections: HashMap<String, Value>, pub registry: Option<String>,
}
Expand description

Serializable agent definition referencing registries by ID.

Can be saved to JSON, loaded from config files, or transmitted over the network. Resolved at runtime via the resolve pipeline into a ResolvedAgent.

Also serves as the runtime behavior configuration passed to hooks via PhaseContext.agent_spec. Plugins read their typed config via spec.config::<K>().

Fields§

§id: String

Unique agent identifier.

§model_id: String

ModelRegistry ID — resolved to a runtime model binding.

§system_prompt: String

System prompt sent to the LLM.

§max_rounds: usize

Maximum inference rounds before the agent stops.

§max_continuation_retries: usize

Maximum continuation retries for truncated LLM responses.

§context_policy: Option<ContextWindowPolicy>

Context window management policy. None disables compaction and truncation.

§reasoning_effort: Option<ReasoningEffort>

Default reasoning effort for this agent. None means no thinking/reasoning. Can be overridden per-run via InferenceOverride or per-step via plugins.

§plugin_ids: Vec<String>

PluginRegistry IDs — resolved at build time.

§active_hook_filter: HashSet<String>

Runtime hook filter: only hooks from plugins in this set will run. Empty = no filtering (all loaded plugins’ hooks run). Distinct from plugin_ids which controls which plugins are loaded.

§allowed_tools: Option<Vec<String>>

Allowed tool IDs (whitelist). None = all tools.

§excluded_tools: Option<Vec<String>>

Excluded tool IDs (blacklist). Applied after allowed_tools.

§endpoint: Option<RemoteEndpoint>

Optional remote endpoint. If set, this agent runs on a remote backend. If None, this agent runs locally.

§delegates: Vec<String>

IDs of sub-agents this agent can delegate to. Each ID must be a registered agent in the AgentSpecRegistry.

§sections: HashMap<String, Value>

Plugin-specific configuration sections (keyed by PluginConfigKey::KEY).

§registry: Option<String>

Registry source this agent was loaded from. None for locally defined agents; Some("cloud") for agents from the “cloud” registry.

Implementations§

Source§

impl AgentSpec

Source

pub fn new(id: impl Into<String>) -> AgentSpec

Create a new agent spec with default settings.

§Examples
use awaken_contract::registry_spec::AgentSpec;

let spec = AgentSpec::new("assistant")
    .with_model_id("gpt-4o-mini")
    .with_system_prompt("You are helpful.")
    .with_max_rounds(10);
assert_eq!(spec.id, "assistant");
assert_eq!(spec.model_id, "gpt-4o-mini");
assert_eq!(spec.system_prompt, "You are helpful.");
assert_eq!(spec.max_rounds, 10);
Source

pub fn config<K>(&self) -> Result<<K as PluginConfigKey>::Config, StateError>
where K: PluginConfigKey,

Read a typed plugin config section. Returns Config::default() if the section is missing. Returns error if the section exists but fails to deserialize.

Source

pub fn set_config<K>( &mut self, config: <K as PluginConfigKey>::Config, ) -> Result<(), StateError>
where K: PluginConfigKey,

Set a typed plugin config section.

Source

pub fn with_model_id(self, model_id: impl Into<String>) -> AgentSpec

Source

pub fn with_system_prompt(self, prompt: impl Into<String>) -> AgentSpec

Source

pub fn with_max_rounds(self, n: usize) -> AgentSpec

Source

pub fn with_reasoning_effort(self, effort: ReasoningEffort) -> AgentSpec

Source

pub fn with_hook_filter(self, plugin_id: impl Into<String>) -> AgentSpec

Source

pub fn with_config<K>( self, config: <K as PluginConfigKey>::Config, ) -> Result<AgentSpec, StateError>
where K: PluginConfigKey,

Set a typed plugin config section (builder variant).

Source

pub fn with_delegate(self, agent_id: impl Into<String>) -> AgentSpec

Source

pub fn with_endpoint(self, endpoint: RemoteEndpoint) -> AgentSpec

Source

pub fn with_section(self, key: impl Into<String>, value: Value) -> AgentSpec

Set a raw JSON section (for tests or untyped usage).

Trait Implementations§

Source§

impl Clone for AgentSpec

Source§

fn clone(&self) -> AgentSpec

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentSpec

Source§

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

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

impl Default for AgentSpec

Source§

fn default() -> AgentSpec

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

impl<'de> Deserialize<'de> for AgentSpec

Source§

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

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

impl JsonSchema for AgentSpec

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 Serialize for AgentSpec

Source§

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

Serialize this value into the given Serde serializer. Read more

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> CloneAny for T
where T: Clone + Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Source§

fn as_any_box(self: Box<T>) -> Box<dyn Any>

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: 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> 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<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>,