tools-system

A tool-registration system for Yuxi agents, covering built-in tools, knowledge-base tools, and MCP tools. It controls how tools are defined and exposed to agents.

In plain words
What is it for?
Use it to add tools, group and label them, expose knowledge tools when needed, and validate the user and target resource before side effects.
Why use it?
It separates registering a tool from authorizing its use, which helps prevent file, network, or database actions from bypassing user permissions.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/xerrors/yuxi/tools-system
Clone the repo
git clone --depth 1 https://github.com/xerrors/Yuxi
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,300 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01300
Opus 5 $0.00000 $0.00650
Sonnet 5 $0.00000 $0.00260
Haiku 4.5 $0.00000 $0.00130

Measured yesterday against content hash c2d5fc17b84e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tools-system scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/tools-system.md · 108 lines

How it starts

The opening of the file, as written. The whole thing — 108 lines — stays where its author put it; the contents beside it link to each section on GitHub.

工具系统

Yuxi 的工具分成三层:内置工具、知识库工具和 MCP 工具。Graph 创建时准备可执行工具,运行时再根据用户权限、Agent 配置和 Skill 激活状态决定模型能看到什么。

注册一个内置工具

普通内置工具使用 @tool 注册:

from yuxi.agents.toolkits.registry import tool


@tool(category="buildin", tags=["示例"], display_name="示例工具")
def example_tool(text: str) -> str:
    """返回处理后的文本。"""
    return text
  • category 用于前端分组,常见值是 buildinknowledgedebug
  • tags 用于展示和筛选;
  • display_name 是给用户看的名称,工具 ID 是给代码和模型协议使用的稳定名称;
  • 工具模块需要被 toolkits 包导入,装饰器才会执行注册。

工具的注册不等于授权。产生文件、网络或数据库副作用的工具必须在执行边界再次校验当前用户和目标资源。

当前内置能力

常用内置工具包括:

工具 作用
ask_user_question 等待用户回答交互式问题
ocr_parse_file 把工作区中受支持的 PDF、Office 或图片转换为 Markdown
present_artifacts 展示当前用户可见的文件产物
install_skill 从允许的沙盒路径或 Git 来源安装个人 Skill;子智能体不可用
web_search 使用已配置的豆包或 Tavily 搜索网页

文件读写和命令执行由 Agent 的 Sandbox backend 提供。present_artifacts 推荐展示当前 Project 的 outputs/ 文件;large_tool_results 和会话摘要等内部文件不会作为交付物展示。

图片生成能力由内置 image-gen Skill 提供,不再作为独立的 Python 工具注册。具体依赖和文件位置由该 Skill 说明。

知识库工具

知识库工具以 @tool(category="knowledge") 注册,但不默认出现在模型工具列表。Agent 激活内置 knowledge-base Skill 后,Skills middleware 才会向模型开放:

工具 作用
list_kbs 列出当前运行可见的知识库
query_kb kb_id 检索片段,返回 kb_idfile_id 和内容
find_kb_document 在指定文件中按关键词或正则定位内容
open_kb_document file_id 分段读取解析后的文档
get_mindmap 读取知识导图
search_file 按文件名搜索可见知识库中的文件
download_kb_file 把有权限的原始文件下载到当前 Project 的 outputs/

工具参数中的 kb_idfile_id 和文件名都会在工具执行处重新检查,不能用模型提示词或 Agent 配置绕过知识库权限。知识库不会挂载为沙盒目录,读取方式见知识库机制详解

需要在 Python 中直接取得知识库工具时:

from yuxi.agents.toolkits.kbs import get_common_kb_tools

kb_tools = get_common_kb_tools()

返回的具体顺序由函数实现维护,不要把顺序当作协议。

工具组装流程

内置 Agent 创建 Graph 时执行:

  1. prepare_agent_runtime_context 按当前用户权限过滤工具、知识库、MCP、Skills 和子智能体。
  2. resolve_configured_runtime_tools(context) 注册 Agent 配置和可见 Skill 依赖的可执行本地工具,并加载配置的 MCP 工具。
  3. SkillsMiddleware 根据当前已预加载或已激活的 Skill,向模型请求开放相应工具 schema。
  4. 工具执行器再次检查具体文件、知识库、MCP 和用户身份。

Read the full file on GitHub · 108 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 108 lines · 0 tokens per session scan A c2d5fc17b84e

Subscribe to this mod's changes

tools-system is an agent published in the GitHub repository xerrors/Yuxi (6,591 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,300 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.