SkillSearchToolkit(*, runtime=None, client=None, middleware=())
Bases: SkillsToolkit
Toolkit for dynamically searching and installing skills from the skills.sh <https://skills.sh>_ ecosystem.
Does not require Node.js. Uses HTTP + GitHub Tarball API directly. A GITHUB_TOKEN environment variable is read automatically to raise the GitHub rate limit from 60 to 5,000 requests per hour.
Example::
import asyncio
from autogen.beta import Agent
from autogen.beta.config import AnthropicConfig
from autogen.beta.tools import SkillSearchToolkit
config = AnthropicConfig(model="claude-sonnet-4-5")
skills = SkillSearchToolkit()
agent = Agent(
"coder",
"You are a helpful coding assistant. Use skills to extend your capabilities.",
config=config,
tools=[skills],
)
async def main():
reply = await agent.ask("Find and install a skill for React best practices, then tell me the top 3 rules.")
print(await reply.content())
asyncio.run(main())
Custom configuration::
from autogen.beta.tools import SkillSearchToolkit, SkillsClientConfig, LocalRuntime
skills = SkillSearchToolkit(
runtime=LocalRuntime(
dir="./my-skills",
extra_paths=["./extra-skills"],
cleanup=True,
timeout=30,
blocked=["rm -rf"],
),
client=SkillsClientConfig(github_token="ghp_...", proxy="http://proxy:8080"),
)
Individual tools are available as attributes::
agent = Agent("a", config=config, tools=[skills.search_skills, skills.install_skill])
Source code in autogen/beta/tools/toolkits/skills/skill_search/toolkit.py
| def __init__(
self,
*,
runtime: SkillRuntime | None = None,
client: SkillsClientConfig | None = None,
middleware: Iterable[ToolMiddleware] = (),
) -> None:
_runtime: SkillRuntime = runtime if runtime is not None else LocalRuntime()
super().__init__(runtime)
_client = SkillsClient(client)
lock = SkillsLock(_runtime.lock_dir / "skills-lock.json")
self.search_skills = _make_search_tool(_client)
self.install_skill = _make_install_tool(_client, lock, _runtime)
self.remove_skill = _make_remove_tool(_runtime, lock)
self.tools.extend([self.search_skills, self.install_skill, self.remove_skill])
|
search_skills = _make_search_tool(_client)
install_skill = _make_install_tool(_client, lock, _runtime)
remove_skill = _make_remove_tool(_runtime, lock)
tools = [(with_middleware(*(_middleware))) for t in tools]
list_skills = _make_list_tool(_runtime)
load_skill = _make_load_tool(_runtime)
run_skill_script = _make_run_tool(_runtime)
Source code in autogen/beta/tools/final/toolkit.py
| async def schemas(self, context: "Context") -> Iterable[ToolSchema]:
schemas: list[ToolSchema] = []
for t in self.tools:
schemas.extend(await t.schemas(context))
return schemas
|
register(stack, context, *, middleware=())
Source code in autogen/beta/tools/final/toolkit.py
| def register(
self,
stack: "ExitStack",
context: "Context",
*,
middleware: Iterable["BaseMiddleware"] = (),
) -> None:
for t in self.tools:
t.register(stack, context, middleware=middleware)
|
tool(function: Callable[..., Any], *, name: str | None = None, description: str | None = None, schema: FunctionParameters | None = None, sync_to_thread: bool = True, middleware: Iterable[ToolMiddleware] = ()) -> FunctionTool
tool(function: None = None, *, name: str | None = None, description: str | None = None, schema: FunctionParameters | None = None, sync_to_thread: bool = True, middleware: Iterable[ToolMiddleware] = ()) -> Callable[[Callable[..., Any]], FunctionTool]
tool(function=None, *, name=None, description=None, schema=None, sync_to_thread=True, middleware=())
Source code in autogen/beta/tools/final/toolkit.py
| def tool(
self,
function: Callable[..., Any] | None = None,
*,
name: str | None = None,
description: str | None = None,
schema: FunctionParameters | None = None,
sync_to_thread: bool = True,
middleware: Iterable[ToolMiddleware] = (),
) -> FunctionTool | Callable[[Callable[..., Any]], FunctionTool]:
def make_tool(f: Callable[..., Any]) -> FunctionTool:
t = FunctionTool.ensure_tool(
tool(
f,
name=name,
description=description,
schema=schema,
sync_to_thread=sync_to_thread,
middleware=middleware,
)
).with_middleware(*self._middleware)
self.tools.append(t)
return t
if function:
return make_tool(function)
return make_tool
|