schema-trim/__init__.py

41 lines
1.6 KiB
Python

"""schema-trim: demote heavy-schema tools from core so tool_search can defer them.
Removes cronjob and delegate_task from _HERMES_CORE_TOOLS at plugin load time.
tool_search (enabled: on) then puts them in the catalog — name + one-line
description on first message, full schema only when the model needs to call them.
Handler, check_fn, and all other registration metadata are untouched.
Safe across hermes updates.
"""
# Tools to demote from "always in schema" to "deferrable via tool_search".
# Only list tools whose full schemas are genuinely expensive and not needed
# on most turns. Keep terminal, file, web, memory, browser in core.
_DEMOTE = (
# Scheduling / delegation — large schemas, situational
"cronjob", "delegate_task",
# Session history — used reactively, not turn 1
"session_search",
# Browser automation — most sessions never touch the browser
"browser_navigate", "browser_snapshot", "browser_click", "browser_type",
"browser_scroll", "browser_back", "browser_press", "browser_get_images",
"browser_vision", "browser_console", "browser_cdp", "browser_dialog",
# Skills management — discovery (skills_list) stays core
"skill_manage", "skill_view",
# Niche / media tools
"image_generate", "text_to_speech", "vision_analyze",
)
def register(ctx):
try:
from toolsets import _HERMES_CORE_TOOLS
for name in _DEMOTE:
if name in _HERMES_CORE_TOOLS:
_HERMES_CORE_TOOLS.remove(name)
except Exception as exc:
import logging
logging.getLogger(__name__).warning(
"schema-trim: failed to demote core tools: %s", exc
)