Files
hermes-agent/model_tools.py
alt-glitch c81362cc59 refactor(tools): the tool list and one tool call become tools/schemas.py and tools/calls.py
model_tools.py held two jobs. tools/schemas.py now builds the tool list sent
to the model: importing it loads the built-in and plugin tools (the moment
`import model_tools` did), and get_tool_definitions selects, rewrites per
session, cleans and defers. tools/calls.py runs one model tool call through
argument repair, hooks, middleware and the registry. Argument repair stays in
tools/arg_coercion.py: the inline executors import it at module top, and in
tools/calls.py that import would load every tool. The error cleaner joins tools/results.py.
Definitions move unchanged. Imports of tools.context and the schema cleaner
that were inside the moved functions go to module top as module objects;
both are loaded by then already, and a patch on, say,
tools.context.hosted_tool_refusal still reaches the code. The imports of
tools.deferral stay inside their functions: Tool Search loads the connectors
on the first tool list, and at module top `import model_tools` would load
them too. calls.py reads get_tool_definitions and _last_resolved_tool_names
through the schemas module, so a patch on either still reaches the call path.

tools/schema_sanitizer.py stays a file. Provider adapters and a provider
plugin import it at module top; inside tools/schemas.py, loading a provider
would load every tool.

Old names, until v0.27.0. model_tools.py is a file of re-exports: the names
releases up to v0.23.5 import from it inside functions, and the public names
pinned catalog plugins import (get_tool_definitions, handle_function_call).
Importing it still loads the tools. No product code imports model_tools now; its own
compatibility tests do, as do ten tests and four eval workers that import it
only to load the tools (the evals also run against older checkouts).

The call path's log lines move from the model_tools logger to tools.calls and
tools.schemas: `hermes logs --component` shows them under tools, not agent.
Argument repair logs as "model_tools", as before.
2026-12-02 04:05:32 +05:30

21 lines
1.2 KiB
Python

"""The old module name of the tool list and the call path, kept for releases and plugins until v0.27.0.
The code is ``tools/schemas.py`` (loading the tools and the tool list sent to the model) and
``tools/calls.py`` (one model tool call). Importing this module still loads the built-in and plugin
tools, through ``tools.schemas``. Nothing in this repository imports it: a process that started on a
release up to v0.23.5 imports some of these names inside functions after an update, and pinned catalog
plugins import the public ones.
"""
from tools.arg_coercion import coerce_tool_args
from tools.calls import (
_AGENT_LOOP_TOOLS, _LEGACY_TOOL_ALIASES, _apply_transform_tool_result_hook, _approval_observability,
_emit_post_tool_call_hook, handle_function_call, suppress_post_tool_call_hook)
from tools.context import CallIds as _CallIds, run_async as _run_async
from tools.results import _sanitize_tool_error
from tools.schemas import (
TOOLSET_REQUIREMENTS, _DYNAMIC_SCHEMA_REWRITERS, _clear_tool_defs_cache, check_tool_availability,
check_toolset_requirements, get_all_tool_names, get_available_toolsets, get_tool_definitions,
get_toolset_for_tool)
from tools.toolsets import _LEGACY_TOOLSET_MAP, _apply_toolset_selection, _select_tool_names