Files
hermes-agent/plugins/delegation/default/__init__.py
Teknium 5c353467dc refactor(delegation): the default delegation strategy is a bundled plugin
Move today's delegation routing (every child follows the delegation section,
else the parent's route) out of core into plugins/delegation/default, a bundled
kind: backend plugin that registers through ctx.register_delegation_provider
like any other strategy. Core keeps only the name 'default' as the fallback
selection; no built-in provider class and no reserved name remain.

The registry loads a bundled strategy on first use when the plugin sweep never
registered it (runtimes that pinned discovery with zero plugins), so
delegate_task never depends on the sweep; plugins.disabled still wins and a
disabled default is a clear refusal. Config names are validated before they
become a path.
2026-10-22 14:48:49 -07:00

39 lines
1.4 KiB
Python

"""Default delegation strategy (``delegation.backend: default``).
Every ``delegate_task`` task takes the route the ``delegation`` config section describes: a
``delegation.base_url`` endpoint, a ``delegation.provider`` pin, ``delegation.model`` and
``delegation.reasoning_effort``, or, when those are empty, the parent's own route. It adds no
schema parameters. Bundled ``kind: backend``, so it is always loaded; other strategies are plugins
of the same kind (``agent/delegation_provider.py``).
"""
from __future__ import annotations
from typing import Any, Mapping
from agent.delegation_provider import DelegationProvider
class DefaultDelegationProvider(DelegationProvider):
"""Route every task through the ``delegation`` section."""
@property
def name(self) -> str:
return "default"
@property
def display_name(self) -> str:
return "Default"
@property
def summary(self) -> str:
return "Every subagent uses delegation.model / delegation.provider, else the parent's model."
def route_task(self, task: Mapping[str, Any], config: Mapping[str, Any]) -> dict[str, Any]:
# The delegation section has no speed tier: an unknown key there never becomes one.
return {k: v for k, v in config.items() if k != "service_tier"}
def register(ctx) -> None:
ctx.register_delegation_provider(DefaultDelegationProvider())