pub struct AgentSkills { /* private fields */ }Expand description
Adds AgentSkills.io skills to an agent (AgentSkills).
The plugin gives the agent a skills tool that loads a skill’s full instructions on demand,
lists the available skills (name, description, location) in the system prompt before each
invocation, and records the activated skills in app_state under its state key.
Skill instances and URLs resolve once for the plugin; paths are read through the agent’s sandbox when the plugin initializes on an agent, so one plugin shared by several agents loads each agent’s skills from its own filesystem.
use strands::Agent;
use strands::testing::MockModel;
use strands::vended_plugins::skills::{AgentSkills, AgentSkillsConfig, Skill, SkillConfig};
let skill = Skill::new(SkillConfig {
name: "my-skill".into(),
description: "A custom skill".into(),
instructions: Some("Do the thing".into()),
..Default::default()
});
let skills = AgentSkills::new(AgentSkillsConfig::builder().skills([skill]).build());
let agent = Agent::builder()
.model(MockModel::new())
.plugins([skills])
.printer(false)
.build()?;Implementations§
Source§impl AgentSkills
impl AgentSkills
Sourcepub fn new(config: AgentSkillsConfig) -> Self
pub fn new(config: AgentSkillsConfig) -> Self
Creates the plugin (new AgentSkills(config)). URL sources are fetched when the plugin
first needs them; paths are read when it initializes on an agent.
Sourcepub async fn get_available_skills(
&self,
agent: Option<&LocalAgent>,
) -> Vec<Skill>
pub async fn get_available_skills( &self, agent: Option<&LocalAgent>, ) -> Vec<Skill>
The available skills: with an agent, that agent’s full set (the plugin’s skills plus those loaded from its paths); without one, the skill instances and URL skills only.
Sourcepub fn set_available_skills(
&self,
skills: impl IntoIterator<Item = impl Into<SkillSource>>,
)
pub fn set_available_skills( &self, skills: impl IntoIterator<Item = impl Into<SkillSource>>, )
Replaces every skill source. Agents load their skills again on
their next invocation or skills call; their activated-skill state is kept.
Sourcepub fn get_activated_skills(&self, agent: &LocalAgent) -> Vec<String>
pub fn get_activated_skills(&self, agent: &LocalAgent) -> Vec<String>
The skills agent activated, most recent last.
Trait Implementations§
Source§impl Clone for AgentSkills
impl Clone for AgentSkills
Source§impl Debug for AgentSkills
impl Debug for AgentSkills
Source§impl Plugin for AgentSkills
impl Plugin for AgentSkills
Source§fn init_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 mut LocalAgent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn init_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 mut LocalAgent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_tools(&self) -> Vec<ToolSource>
fn get_tools(&self) -> Vec<ToolSource>
init_agent:
anything that converts into a ToolSource, such as vec![MyTool.into()]. An MCP client
is rejected; pass it to the agent’s tools instead.Auto Trait Implementations§
impl !RefUnwindSafe for AgentSkills
impl !UnwindSafe for AgentSkills
impl Freeze for AgentSkills
impl Send for AgentSkills
impl Sync for AgentSkills
impl Unpin for AgentSkills
impl UnsafeUnpin for AgentSkills
Blanket Implementations§
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more