agent-tool

GitHub

指导如何在AI代理项目中新增、注册并测试工具函数,支持多种框架。用于扩展助手能力,定义异步工具逻辑、暴露接口及配置系统提示词。

template/{{cookiecutter.project_slug}}/.claude/skills/agent-tool/SKILL.md vstorm-co/full-stack-ai-agent-template

Trigger Scenarios

需要为AI代理添加新的功能或API调用 扩展助手的行动能力 集成外部服务到Agent

Install

npx skills add vstorm-co/full-stack-ai-agent-template --skill agent-tool -g -y
More Options

Non-standard path

npx skills add https://github.com/vstorm-co/full-stack-ai-agent-template/tree/main/template/{{cookiecutter.project_slug}}/.claude/skills/agent-tool -g -y

Use without installing

npx skills use vstorm-co/full-stack-ai-agent-template@agent-tool

指定 Agent (Claude Code)

npx skills add vstorm-co/full-stack-ai-agent-template --skill agent-tool -a claude-code -g -y

安装 repo 全部 skill

npx skills add vstorm-co/full-stack-ai-agent-template --all -g -y

预览 repo 内 skill

npx skills add vstorm-co/full-stack-ai-agent-template --list

SKILL.md

Frontmatter
{
    "name": "agent-tool",
    "description": "Add a new tool\/function the AI agent can call (e.g. look something up, hit an external API, perform an action). Use when extending the assistant's capabilities, wiring a new function into the agent, or when the model needs a new action. This project uses {{ cookiecutter.ai_framework }}."
}

Add an Agent Tool ({{ cookiecutter.ai_framework }})

Agent tools live in backend/app/agents/tools/ and are surfaced to the model so it can call them mid-conversation. The assistant is defined in backend/app/agents/.

Steps

  1. Write the tool function in backend/app/agents/tools/<tool_name>.py:

    • Async, fully type-hinted, with a clear docstring — the docstring and signature are what the model sees, so make them precise.
    • Pure logic: take typed args, return a JSON-serializable result. Raise on hard errors; return a structured {"error": ...} for soft failures the model should reason about.
    • Keep secrets/IO behind settings and the service layer; don't inline credentials.
  2. Export it from backend/app/agents/tools/__init__.py (add the import and append to __all__, matching the existing feature-gated blocks).

  3. Register it on the agent in the assistant for the active framework: {%- if cookiecutter.use_pydantic_ai %}

    • app/agents/assistant.py — decorate with @agent.tool (needs RunContext[Deps]) or @agent.tool_plain (no context):
      @agent.tool
      async def my_tool(ctx: RunContext[Deps], query: str) -> dict:
          """One-line description the model reads to decide when to call this."""
          ...
      

{%- elif cookiecutter.use_pydantic_deep %}

  • app/agents/pydantic_deep_assistant.py — add the function to the agent's tool list. {%- elif cookiecutter.use_langchain %}
  • app/agents/langchain_assistant.py — wrap with @tool and add it to the tools=[...] passed to the agent. {%- elif cookiecutter.use_langgraph %}
  • app/agents/langgraph_assistant.py — wrap with @tool and include it in the tools list bound to the graph. {%- elif cookiecutter.use_deepagents %}
  • app/agents/deepagents_assistant.py — add the function to the agent's tool list. {%- endif %}
  1. Prompt guidance (optional but recommended): if the tool should only be used in specific situations, add a sentence to the system prompt in app/agents/prompts.py so the model knows when to reach for it.

  2. Frontend rendering (optional): tool calls render as cards in the chat UI. For a bespoke card, add a renderer under frontend/src/components/chat/tool-results/; otherwise the generic card handles it.

  3. Test it: add backend/tests/test_<tool_name>.py (see existing test_web_search.py / test_chart_tool.py). Tools are plain async functions — test them directly, no agent needed.

Rules

  • The docstring is the contract with the model — keep it accurate and action-oriented.
  • Return small, structured payloads; don't dump huge blobs into the context.
  • Long-running or side-effecting work belongs in a service (and possibly a background task), not inline in the tool.
  • See docs/howto/add-agent-tool.md for a fuller walkthrough.

Version History

  • 0.2.16 Current 2026-07-25 10:05

Same Skill Collection

template/{{cookiecutter.project_slug}}/.claude/skills/alembic-migration/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/background-task/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/billing-stripe/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/channel-bot/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/frontend-feature/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/pytest-suite/SKILL.md
template/{{cookiecutter.project_slug}}/.claude/skills/rag-knowledge/SKILL.md

Metadata

Files
0
Version
0.2.19
Hash
1f0db503
Indexed
2026-07-25 10:05

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-02 20:34
浙ICP备14020137号-1