From 9cf7c740305bb44b649f7adf999c16562e773d9a Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 19:43:56 -0700 Subject: [PATCH] refactor(delegate): module headers condensed (one-line docstrings, logger comment inline) --- tools/delegate_tool_child_run.py | 9 ++------- tools/delegate_tool_config.py | 8 ++------ tools/delegate_tool_dispatch.py | 11 ++++------- tools/delegate_tool_progress.py | 8 ++------ tools/delegate_tool_registry.py | 8 ++------ tools/delegate_tool_results.py | 8 ++------ tools/delegate_tool_tasks.py | 5 +---- tools/delegate_tool_toolsets.py | 8 ++------ 8 files changed, 17 insertions(+), 48 deletions(-) diff --git a/tools/delegate_tool_child_run.py b/tools/delegate_tool_child_run.py index 9db3d2e243..70dcf74dea 100644 --- a/tools/delegate_tool_child_run.py +++ b/tools/delegate_tool_child_run.py @@ -1,9 +1,5 @@ """Running ONE pre-built child agent: heartbeat, registry entry, workspace seeding, -timeout/failure handling, result-entry assembly and cleanup (``_ChildRun``). - -Split out of ``tools/delegate_tool.py``; every moved name is re-imported there, so -``tools.delegate_tool.`` keeps resolving (and monkeypatching) as before. -""" +timeout/failure handling, result-entry assembly and cleanup (``_ChildRun``).""" from __future__ import annotations @@ -25,8 +21,7 @@ from tools.delegate_tool_results import ( _extract_output_tail, _looks_like_error_output, _stringify_tool_content, _summarize_tool_arguments, ) -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module def _num(value: Any, default: int = 0) -> int: """int() for counters that may be mocks/None on test doubles.""" diff --git a/tools/delegate_tool_config.py b/tools/delegate_tool_config.py index 43569172ac..de0b2c99d6 100644 --- a/tools/delegate_tool_config.py +++ b/tools/delegate_tool_config.py @@ -1,7 +1,4 @@ -"""Delegation config knobs (delegation.* keys) and child credential/provider resolution. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""Delegation config knobs (delegation.* keys) and child credential/provider resolution.""" from __future__ import annotations @@ -10,8 +7,7 @@ import os from typing import Any, Dict, List, Optional from utils import base_url_hostname, is_truthy_value -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module # Runtime-provider sentinel for providers that are not natively known; must # match hermes_cli.runtime_provider.RUNTIME_PROVIDER_TYPE_CUSTOM. diff --git a/tools/delegate_tool_dispatch.py b/tools/delegate_tool_dispatch.py index 090a81dff9..a0f2959ee0 100644 --- a/tools/delegate_tool_dispatch.py +++ b/tools/delegate_tool_dispatch.py @@ -1,8 +1,6 @@ -"""Batch execution + background dispatch for delegate_task. - -``delegate_task`` builds a ``_Batch`` (children + origin identity) and hands it to -``_run_batch``; everything here runs it synchronously or as ONE detached async unit. -""" +"""Batch execution + background dispatch for delegate_task: ``delegate_task`` builds a ``_Batch`` +(children + origin identity) and hands it to ``_run_batch``, which runs it synchronously or as ONE +detached async unit.""" from __future__ import annotations @@ -21,8 +19,7 @@ from tools.delegate_tool_progress import ( from tools.delegate_tool_registry import _capture_gateway_steer_authority from tools.delegate_tool_results import _finalize_child_results -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module @dataclass diff --git a/tools/delegate_tool_progress.py b/tools/delegate_tool_progress.py index 28db6b1a77..520eefdae9 100644 --- a/tools/delegate_tool_progress.py +++ b/tools/delegate_tool_progress.py @@ -1,7 +1,4 @@ -"""Child progress relay, console formatting and child system-prompt construction for delegate_task. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""Child progress relay, console formatting and child system-prompt construction for delegate_task.""" from __future__ import annotations @@ -13,8 +10,7 @@ from contextlib import contextmanager from typing import Any, Dict, List, Optional from tools.delegate_tool_registry import _active_subagents, _active_subagents_lock -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module # Terminal child statuses that mean "the subagent did NOT deliver a usable result". Shared by the CLI spinner echo, # the gateway failure notice, and the parent-facing failure summary so every surface agrees. diff --git a/tools/delegate_tool_registry.py b/tools/delegate_tool_registry.py index 64991b3c90..43d295d9ec 100644 --- a/tools/delegate_tool_registry.py +++ b/tools/delegate_tool_registry.py @@ -1,7 +1,4 @@ -"""Live-subagent registry + model-facing control plane (list/steer/stop) for delegate_task. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""Live-subagent registry + model-facing control plane (list/steer/stop) for delegate_task.""" from __future__ import annotations @@ -13,8 +10,7 @@ from typing import Any, Dict, List, Optional from agent.interrupt_compat import request_hard_interrupt from tools.registry import tool_error -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module _spawn_pause_lock = threading.Lock() _spawn_paused: bool = False diff --git a/tools/delegate_tool_results.py b/tools/delegate_tool_results.py index 52daf1eeb5..1690e8a37e 100644 --- a/tools/delegate_tool_results.py +++ b/tools/delegate_tool_results.py @@ -1,7 +1,4 @@ -"""Subagent result post-processing: summary budget/spill, tool-trace summaries, lifecycle hooks and cost rollup. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""Subagent result post-processing: summary budget/spill, tool-trace summaries, lifecycle hooks and cost rollup.""" from __future__ import annotations @@ -11,8 +8,7 @@ import threading from typing import Any, Dict, List, Optional from urllib.parse import urlsplit, urlunsplit -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module def _stringify_tool_content(content: Any) -> str: """Stable text for tool-result content. Some OpenAI-compatible paths return diff --git a/tools/delegate_tool_tasks.py b/tools/delegate_tool_tasks.py index df4dd6b7ed..4c393a3219 100644 --- a/tools/delegate_tool_tasks.py +++ b/tools/delegate_tool_tasks.py @@ -1,7 +1,4 @@ -"""delegate_task input validation: tasks=[...] / legacy goal normalisation and per-task output schemas. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""delegate_task input validation: tasks=[...] / legacy goal normalisation and per-task output schemas.""" from __future__ import annotations diff --git a/tools/delegate_tool_toolsets.py b/tools/delegate_tool_toolsets.py index a28eb4b4b1..be75cf95a5 100644 --- a/tools/delegate_tool_toolsets.py +++ b/tools/delegate_tool_toolsets.py @@ -1,7 +1,4 @@ -"""Child toolset resolution for delegate_task: what a child may and may never use. - -Split out of ``tools/delegate_tool.py``, which re-imports every name (patch targets stay valid). -""" +"""Child toolset resolution for delegate_task: what a child may and may never use.""" from __future__ import annotations @@ -11,8 +8,7 @@ from typing import List, Optional from toolsets import TOOLSETS from tools.delegate_tool_config import _get_inherit_mcp_toolsets -# Log-record parity with the origin module. -logger = logging.getLogger("tools.delegate_tool") +logger = logging.getLogger("tools.delegate_tool") # log-record parity with the origin module # Tools that children must never have access to DELEGATE_BLOCKED_TOOLS = frozenset(