Files
myWiki/concepts/tool-registry.md

33 lines
949 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "ToolRegistry"
created: 2026-05-11
updated: 2026-05-11
type: concept
tags: [agent-architecture, tool-design, api]
sources: [[prompt-caching-architecture]]
---
# ToolRegistry
## 定义
ToolRegistry 是 [[stub-pattern|Stub 模式]] 中的核心组件提供统一的工具调用接口。Agent 通过 ToolRegistry 间接调用具体工具,而非直接与工具定义交互。
## 工作流程
1. Agent 决策:调用 `ToolRegistry.invoke("fetch_factor_data", {ticker: "AAPL", time_range: "1d"})`
2. ToolRegistry 解析工具标识符,查找对应实现
3. 动态加载/执行具体逻辑,返回结果
4. 对 Agent 而言ToolRegistry 的定义在会话中**从未改变**
## 工程价值
- 隔离工具定义变更对缓存的影响
- 支持运行时动态注册/卸载工具(对缓存透明)
- 统一错误处理和日志记录入口
## 相关概念
- [[stub-pattern|Stub 模式]]
- [[prompt-caching|Prompt Caching]]