GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing doc.agentscope.io — Agent Skill - AgentScope Note Go to the end to download the full example code. Agent Skill¶Agent skill is an approach proposed by Anthropic to improve agent capabilities on specific tasks. AgentScope provides built-in support for Agent Skills through the The related APIs are as follows:
In this section we demonstrate how to register agent skills and use them in an ReAct agent. import os from agentscope.agent import ReActAgent from agentscope.formatter import DashScopeChatFormatter from agentscope.memory import InMemoryMemory from agentscope.model import DashScopeChatModel from agentscope.tool import Toolkit Registering Agent Skills¶First, we need to prepare an agent skill directory, which follows the requirements specified in the Anthropic blog. Note The skill directory must contain a Here, we fake an example skill directory --- name: sample_skill description: A sample agent skill for demonstration. --- # Sample Skill ... os.makedirs("sample_skill", exist_ok=True) with open("sample_skill/SKILL.md", "w", encoding="utf-8") as f: f.write( """--- name: sample_skill description: A sample agent skill for demonstration. --- # Sample Skill ... """, ) Then, we can register the skill using the toolkit = Toolkit() toolkit.register_agent_skill("sample_skill") After that, we can get the prompt for all registered agent skills using the
agent_skill_prompt = toolkit.get_agent_skill_prompt() print("Agent Skill Prompt:") print(agent_skill_prompt) Agent Skill Prompt: # Agent Skills The agent skills are a collection of folds of instructions, scripts, and resources that you can load dynamically to improve performance on specialized tasks. Each agent skill has a `SKILL.md` file in its folder that describes how to use the skill. If you want to use a skill, you MUST read its `SKILL.md` file carefully. ## sample_skill A sample agent skill for demonstration. Check "sample_skill/SKILL.md" for how to use this skill Of course, we can customize the prompt template when creating the toolkit = Toolkit( # The instruction that introduces how to use the skill to the agent/llm agent_skill_instruction="<system-info>You're provided a collection of skills, each in a directory and described by a SKILL.md file.</system-info>\n", # The template for formatting each skill's prompt, must contain # {name}, {description}, and {dir} fields agent_skill_template="- {name}({dir}): {description}", ) toolkit.register_agent_skill("sample_skill") agent_skill_prompt = toolkit.get_agent_skill_prompt() print("Customized Agent Skill Prompt:") print(agent_skill_prompt) Customized Agent Skill Prompt: <system-info>You're provided a collection of skills, each in a directory and described by a SKILL.md file.</system-info> - sample_skill(sample_skill): A sample agent skill for demonstration. Integrating Agent Skills with ReActAgent¶The ReActAgent class in AgentScope will attach the agent skill prompt to the system prompt automatically. We can create a ReAct agent with the registered agent skills as follows: Important When using agent skills, the agent must be equipped with text file reading or shell command tools to access the skill instructions in SKILL.md files. agent = ReActAgent( name="Friday", sys_prompt="You are a helpful assistant named Friday.", model=DashScopeChatModel( model_name="qwen3-max", api_key=os.environ["DASHSCOPE_API_KEY"], ), memory=InMemoryMemory(), formatter=DashScopeChatFormatter(), toolkit=toolkit, ) print("Agent's System Prompt with Agent Skills:") print(agent.sys_prompt) Agent's System Prompt with Agent Skills: You are a helpful assistant named Friday. <system-info>You're provided a collection of skills, each in a directory and described by a SKILL.md file.</system-info> - sample_skill(sample_skill): A sample agent skill for demonstration. Total running time of the script: (0 minutes 0.004 seconds) | ||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |