create-tool
Author a new @tool-decorated Python file in the agent workspace, validate it, and register it via reload().
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-22
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- create-tool
- tools
- [ "write", "create_tool", "reload", "read", "bash" ]
- version
- 1.0.0
- triggers
- [ "add a tool", "build a tool", "extend yourself", "write a tool that", "I need a tool to" ]
- description
- Author a new @tool-decorated Python file in the agent workspace, validate it, and register it via reload().
02 资源文件 5
- 参考文档references/ast-blocked-list.md2.3 KB
- 参考文档references/decorator-fields.md1.8 KB
- 参考文档references/examples-good-and-bad.md3.2 KB
- 脚本scripts/validate.py1.4 KB
- 其他templates/tool.py.template722 B
03 SKILL.md 正文
Resources
(auto-filled by the loader)
Contract
Inputs you must have:
- A clear, single-sentence statement of what the new tool does.
- Argument names with concrete types (
str,int,bool,list[str]). - A description of the success-case return string.
Outputs the agent must produce:
- A
.pyfile atworkspace/capabilities/<name>.pydecorated with@tool(...). - A
reload()call aftercreate_toolsucceeds. - A test invocation of the new tool to confirm it works.
Don't proceed if the user's request is ambiguous about WHEN the tool should be called. Ask.
Knowledge
The @tool decorator lives in arcagent.tools._decorator. Its full field list is in references/decorator-fields.md. The AST validator that create_tool runs is documented in references/ast-blocked-list.md — read it before writing source that touches files, network, or imports beyond typing/dataclasses. Good and bad tool authoring patterns are in references/examples-good-and-bad.md.
The version field is required and must match the bumped version when calling update_tool later. Start at "1.0.0".
classification is the safety guard: "read_only" if the tool only reads state (and is therefore parallel-safe), "state_modifying" for anything that writes, calls subprocesses, or touches external state. Default to "state_modifying" — when unsure, the safer choice loses concurrency, never correctness.
when_to_use is the LLM-facing hint shown in the system prompt's tool manifest. Keep it under 80 characters and lead with the trigger phrase ("When you need to ...").
Steps
- Read this SKILL.md once. Don't re-read mid-task.
- Decide the tool's name (snake_case, valid Python identifier) and write a one-line description.
- Compose the source body — use
templates/tool.py.templateas the starting point. - Call
create_tool(name=..., source=...). If it returnsError: AST validation rejected ..., read the rejection category, fix the offending pattern (it's almost always a privileged import orgetattron a denied attribute), and try again. - Call
reload(). The diff string should mention+1 added (<your-name>). - Invoke your new tool with sample arguments to confirm it works end-to-end.
- If anything is wrong, call
update_tool(name=..., new_source=..., version_bump="patch")— never delete and re-create.
Anti Patterns
- Don't auto-call
reload()from insidecreate_tool. The split is intentional: write many capabilities, reload once. - Don't put workspace paths in the source body. Use the runtime context (
from arcagent.builtins.capabilities import _runtime; _runtime.workspace()). - Don't import
os,sys,subprocess,socket,ctypes,pickle,marshal,shelve, or any module not in the AST validator's allowlist. The validator will reject the source and your call tocreate_toolwill fail. - Don't name your tool the same as an existing one —
create_toolrejects collisions. Useupdate_toolinstead. - Don't skip the test invocation in step 6. A tool that registers but doesn't work wastes context for every future LLM call.
Examples
# Good — read-only, single-purpose, classification correct
@tool(
description="Count lines in a workspace file",
classification="read_only",
capability_tags=["file_read"],
when_to_use="When you need a quick line count without reading the whole file",
version="1.0.0",
)
async def line_count(file_path: str) -> str:
from arcagent.builtins.capabilities import _runtime
from arcagent.tools._validation import resolve_workspace_path
p = resolve_workspace_path(file_path, _runtime.workspace())
return str(sum(1 for _ in p.open()))
Validation
Before declaring the new tool done:
create_toolreturnedCreated tool ....reload()returned a diff containing+1 added.- A live invocation returned the expected output.
scripts/validate.py(if you wrote one alongside the tool) exits 0.
04 同仓库更多 Skills
笔记读取
notes
使用 notes_echo 工具回读笔记内容。
ArcFlow 工作流构建
workflow-builder
将对话中描述的可重复业务流程,转化为经过命名和验证的 ArcFlow 工作流草稿。
@tool 工具源文件更新
update-tool
更新 workspace/capabilities/ 目录下现有的 @tool 源文件,并按 major/minor/patch 规则递增其语义化版本(semver)。
update-skill
Update an existing skill's SKILL.md body in workspace/capabilities/skills/, bumping its frontmatter semver.
create-skill
Scaffold a new skill folder under workspace/capabilities/skills/ with frontmatter and the seven required sections.
sqlite
Use the SQLite connector to read the operator's semantic layer and make bounded typed reads of an approved database file. Trigger for questions about data in a connected SQLite database; skip for writes, schema changes, or raw SQL.