Tools Runtime
الأدوات Runtime
Start with meaning, then move to detail.
This lesson explains Tools Runtime as part of Hermes internals and extension points. You will learn what it does, when it matters, and the smallest safe test that proves it works.
If you are new, do not memorize names. Focus on three questions: what problem does this solve, what access does it need, and how can you verify the result?
For practice, inspect the first example, identify its effects, run it on test data, and compare the result with the source claim.
For advanced readers, inspect Tool registration model, How registry.register() works, Discovery: discoverbuiltintools(), then verify failure modes and version compatibility.
Know Python, Git, and basic project structure before changing code.
A clear outcome before you read.
- Understand Tools Runtime without assumed prior knowledge.
- Separate the source description from what still needs testing in your environment.
- Read the first command and identify its inputs and outputs before copying it.
Short definitions before the details.
- Provider
- The service that runs or provides access and authentication to a model.
- Tool
- A structured action the agent can call to read or change something.
Runtime behavior of the tool registry, toolsets, dispatch, and terminal environments
What does the source say, and in what order?
- 01Tool registration model
Start here to understand the core idea or structure.
- 02How registry.register() works
Read this after the foundation, then connect it to the previous step.
- 03Discovery: discoverbuiltintools()
Read this after the foundation, then connect it to the previous step.
- 04Tool availability checking (checkfn)
Read this after the foundation, then connect it to the previous step.
- 05Toolset resolution
Read this after the foundation, then connect it to the previous step.
- 06How gettooldefinitions() filters tools
Read this after the foundation, then connect it to the previous step.
- 07Legacy toolset names
Read this after the foundation, then connect it to the previous step.
- 08Dispatch
Read this after the foundation, then connect it to the previous step.
- 09Dispatch flow: model toolcall → handler execution
Read this after the foundation, then connect it to the previous step.
- 10Error wrapping
Finish here to verify the result and special cases.
Copy only after you understand the effect.
Each call creates a `ToolEntry` stored in the singleton `ToolRegistry._tools` dict keyed by tool name. A registration that would shadow an existing tool from a **different** toolset is rejected (with an error log) unless the caller passes `override=True`; plugin overrides of built-in tools additionally require the operator opt-in `plugins.entries.<plugin_id>.allow_tool_override: true` in `config.yaml`.
`schema["description"]` is the authoritative model-facing description. The separate `description=` argument populates `ToolEntry.description`; when it is omitted, the registry metadata falls baThis auto-discovery means new tool files are picked up automatically — no manual list to maintain. The AST check only matches top-level `registry.register()` calls (not calls inside functions), so helper modules in `tools/` are not imported.
Each import triggers the module's `registry.register()` calls. Errors in optional tools (e.g., missing `fal_client` for image generation) are caught and logged — they don't prevent other tools from loading.
After core tool discovery, MCP tools and plugin tools are also discovered:
1. **MCP tools** — `tools.mcp_tool.discover_mcp_tools()` reads MCP serverKey behaviors:
- Check results are **cached per-call** — if multiple tools share the same `check_fn`, it only runs once.
- Exceptions in `check_fn()` are treated as "unavailable" (fail-safe).
- The `is_toolset_available()` method checks whether a toolset's `check_fn` passes, used for UI display and toolset resolution.
## Toolset resolution
Toolsets are named bundles of tools. Hermes resolves them through:
- explicit enabled/disabled toolset lists
- platform presets (`hermes-cli`, `hermes-telegram`, etc.)
- dynamic MCP toolsets
- curated special-purpose sets like `hermes-acp`
### How `get_tRead the first command and identify its inputs and outputs before copying it.
Match every command to your installed Hermes version, review the files and accounts it can reach, and use non-sensitive data for the first test. If this explanation differs from the source, the official source wins.