The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(oneshot): one-shot runs keep skill_manage
Tekniumd7094033f6f0
diff --git a/agent/agent_init.py b/agent/agent_init.pyindex ee1aedc9521..1d2d7f302e4 100644--- a/agent/agent_init.py+++ b/agent/agent_init.py@@ -1117,9 +1117,6 @@ def _load_tools(agent, enabled_toolsets, disabled_toolsets):agent.disabled_toolsets = disabled_toolsets # so the tool_search bridge and delegate children drop them tooagent.tools = model_tools.get_tool_definitions(enabled_toolsets=enabled_toolsets, disabled_toolsets=disabled_toolsets, quiet_mode=agent.quiet_mode)- # A finite -q run has no later session to learn for: no skill authoring tool (agent/oneshot_footprint.py).- from agent.oneshot_footprint import prune_oneshot_tools- agent.tools = prune_oneshot_tools(agent.tools or [])if drops := agent_tool_drops(agent):agent.tools = [t for t in agent.tools if t["function"]["name"] not in drops]diff --git a/agent/oneshot_footprint.py b/agent/oneshot_footprint.pyindex 2ef77cc6eca..236f14462a7 100644--- a/agent/oneshot_footprint.py+++ b/agent/oneshot_footprint.py@@ -4,10 +4,10 @@ A one-shot run has no later session in its HERMES_HOME to learn for: the processexits. The interactive self-improvement loop is pure overhead there, and a measured one — across 21one-shot benchmark trajectories the agent authored 7 new skills and patched a bundled one mid-task, 37 of~215 tool calls were ``skill_view``/``skill_manage``, and skill text was 34% of every tool-result byte fed-back into context. Three rules follow, all keyed on the same session marker the approval gate and the-delegation dispatcher already read (``HERMES_SINGLE_QUERY_SESSION``), so interactive sessions are untouched:+back into context. Two rules follow, both keyed on the same session marker the approval gate and the+delegation dispatcher already read (``HERMES_SINGLE_QUERY_SESSION``), so interactive sessions are untouched+(``skill_manage`` itself stays offered: a one-shot may still author skills):-* ``skill_manage`` is not offered (``skills_list``/``skill_view`` stay: reading a domain skill can still win);* the ## Skills prompt drops the "record it / patch it / offer to save" coaching and the "load process skillseven for tasks you already know" push, keeping only "load a skill when it adds knowledge you lack";* delegation is capped per session (``delegation.oneshot_max_children``): subagents each re-pay a cold@@ -16,10 +16,6 @@ delegation dispatcher already read (``HERMES_SINGLE_QUERY_SESSION``), so interac"""from __future__ import annotations-from typing import Any, Dict, Iterable, List--ONESHOT_HIDDEN_TOOLS = frozenset({"skill_manage"})-def is_single_query_session() -> bool:"""The finite ``-q`` marker, read through the session env so gateway-bound sessions never see it.@@ -43,14 +39,6 @@ def is_single_query_session() -> bool:return str(get_session_env("HERMES_SINGLE_QUERY_SESSION", "") or "") == "1"-def prune_oneshot_tools(tools: Iterable[dict[str, Any]]) -> list[dict[str, Any]]:- """*tools* minus ``ONESHOT_HIDDEN_TOOLS``; identity when the session is not one-shot."""- tools = list(tools)- if not is_single_query_session():- return tools- return [t for t in tools if (t.get("function") or {}).get("name") not in ONESHOT_HIDDEN_TOOLS]--ONESHOT_SKILLS_LOAD_GUIDANCE = ("## Skills\n""Scan the skills below and load one with skill_view(name) only when it carries domain knowledge you lack "diff --git a/gateway/session_local_inventory.py b/gateway/session_local_inventory.pyindex f2e98622841..111c256fa0c 100644--- a/gateway/session_local_inventory.py+++ b/gateway/session_local_inventory.py@@ -43,9 +43,8 @@ def _grouped(tools):def _policy_tools(policy, config):"""The tool list the session's next agent build loads (``agent/agent_init.py`` tool snapshot):- the policy's toolsets minus the configured and platform-gated disabled ones, one-shot pruned."""+ the policy's toolsets minus the configured and platform-gated disabled ones."""import model_tools- from agent.oneshot_footprint import ONESHOT_HIDDEN_TOOLSfrom agent.skill_utils import parse_config_string_listfrom toolsets import session_disabled_toolsets, session_platform_tool_dropsenabled = list(policy.current_toolsets(config))@@ -53,8 +52,6 @@ def _policy_tools(policy, config):parse_config_string_list((config.get("agent") or {}).get("disabled_toolsets")) or None, policy.platform)tools = model_tools.get_tool_definitions(enabled_toolsets=enabled, disabled_toolsets=disabled, quiet_mode=True)drops = set(session_platform_tool_drops(policy.platform))- if policy.source == "oneshot":- drops |= ONESHOT_HIDDEN_TOOLSreturn enabled, [tool for tool in tools or [] if tool["function"]["name"] not in drops]diff --git a/tests/agent/test_oneshot_footprint.py b/tests/agent/test_oneshot_footprint.pyindex 80302a6bd80..8d2acdc736a 100644--- a/tests/agent/test_oneshot_footprint.py+++ b/tests/agent/test_oneshot_footprint.py@@ -1,4 +1,4 @@-"""One-shot sessions (``hermes chat -q``) drop the self-improvement footprint.+"""One-shot sessions (``hermes chat -q``) trim the self-improvement prompt footprint.Across 21 one-shot benchmark trajectories the agent created 7 skills and patched a bundled onemid-task, spent 37 of ~215 tool calls on skill_view/skill_manage, and spawned review subagents of@@ -22,13 +22,9 @@ def _tools(*names):return [{"type": "function", "function": {"name": n}} for n in names]-def test_oneshot_hides_skill_manage_and_skill_authoring_coaching(oneshot, interactive_prompt, tmp_path):- """-q: no skill_manage tool and a skills prompt that neither asks to save/patch skills nor pushes process- skills; skill reading stays. The interactive prompt for the same skills dir is the control."""- kept = {t["function"]["name"] for t in oneshot_footprint.prune_oneshot_tools(- _tools("skill_manage", "skill_view", "skills_list", "terminal"))}- assert "skill_manage" not in kept and {"skill_view", "skills_list", "terminal"} <= kept-+def test_oneshot_skills_prompt_drops_authoring_coaching(oneshot, interactive_prompt, tmp_path):+ """-q: a skills prompt that neither asks to save/patch skills nor pushes process skills; skill reading+ stays. The interactive prompt for the same skills dir is the control."""prompt = build_skills_system_prompt(available_tools={"skill_view", "skills_list"}, skills_dir_override=_skills_dir(tmp_path))assert "demo-skill" in prompt and "skill_view" in promptassert "skill_manage" not in prompt and "offer to save as a skill" not in prompt@@ -65,28 +61,30 @@ def test_oneshot_delegation_budget_charges_total_children_then_refuses(oneshot,assert delegate_tool._oneshot_spawn_budget(parent, 50) is None-def test_gateway_owned_oneshot_session_takes_its_footprint_from_the_frozen_policy(tmp_path, monkeypatch):+def test_gateway_owned_oneshot_session_keeps_skill_manage_and_takes_its_prompt_from_the_frozen_policy(tmp_path, monkeypatch):"""The gateway daemon never has the client's HERMES_SINGLE_QUERY_SESSION: a `chat -q` session it owns is- one-shot by its frozen ``oneshot`` source, so it gets main's in-process -q shape (no skill_manage, no- authoring coaching). An interactive session's policy wins over a stray daemon env marker, keeping its- tools[] and system prompt (the prompt-cache prefix) unchanged."""+ one-shot by its frozen ``oneshot`` source, so it gets the one-shot skills prompt; its tool list still offers+ skill_manage (one-shots may author skills). An interactive session's policy wins over a stray daemon env+ marker, keeping its system prompt (the prompt-cache prefix) unchanged."""+ from gateway.session_local_inventory import _policy_toolsfrom gateway.session_policy import build_policy, policy_scopemonkeypatch.delenv("HERMES_SINGLE_QUERY_SESSION", raising=False)skills = _skills_dir(tmp_path)def shape(source):- with policy_scope(build_policy({"source": source, "cwd": str(tmp_path), "model": "m"}, {})):- names = {t["function"]["name"] for t in oneshot_footprint.prune_oneshot_tools(_tools("skill_manage", "skill_view"))}+ policy = build_policy({"source": source, "cwd": str(tmp_path), "model": "m"}, {})+ with policy_scope(policy):+ names = {t["function"]["name"] for t in _policy_tools(policy, {})[1]}prompt = build_skills_system_prompt(available_tools={"skill_view", "skills_list", "skill_manage"},skills_dir_override=skills)return names, promptnames, prompt = shape("oneshot")- assert names == {"skill_view"}+ assert "skill_manage" in namesassert prompt.startswith(oneshot_footprint.ONESHOT_SKILLS_LOAD_GUIDANCE) and "offer to save as a skill" not in promptinteractive = build_skills_system_prompt(available_tools={"skill_view", "skills_list", "skill_manage"},skills_dir_override=skills)monkeypatch.setenv("HERMES_SINGLE_QUERY_SESSION", "1") # inherited by a daemon a -q client auto-started- assert shape("cli") == ({"skill_manage", "skill_view"}, interactive)+ assert shape("cli")[1] == interactivediff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 9caa4602aca..1f66c5d4ad1 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -3072,7 +3072,7 @@ The delegation provider uses the same credential resolution as CLI/gateway start**Precedence:** `delegation.base_url` in config → `delegation.provider` in config → parent provider (inherited). `delegation.model` in config → parent model (inherited). Setting just `model` without `provider` changes only the model name while keeping the parent's credentials (useful for switching models within the same provider like OpenRouter).-**One-shot runs:** a finite `hermes chat -q` / `--oneshot` session has no later turn to consume delegated results and no later session to learn for, so it runs a smaller footprint: `skill_manage` is not offered (skills are still listed and loadable with `skill_view`), the skills prompt asks for domain skills only rather than process skills, and `oneshot_max_children` caps the total subagents the run may spawn (default `2`, `0` = unlimited). Past the cap `delegate_task` returns a tool error telling the agent to finish inline.+**One-shot runs:** a finite `hermes chat -q` / `--oneshot` session has no later turn to consume delegated results and no later session to learn for, so it runs a smaller footprint: the skills prompt asks for domain skills only rather than process skills (`skill_manage` stays available, so the run can still author skills), and `oneshot_max_children` caps the total subagents the run may spawn (default `2`, `0` = unlimited). Past the cap `delegate_task` returns a tool error telling the agent to finish inline.**Width and depth:** `max_concurrent_children` caps how many subagents run in parallel per batch (default `3`, floor of 1, no ceiling). Can also be set via the `DELEGATION_MAX_CONCURRENT_CHILDREN` env var. When the model submits a `tasks` array longer than the cap, `delegate_task` returns a tool error explaining the limit rather than silently truncating. `max_spawn_depth` controls the delegation tree depth (clamped to 1-3). At the default `1`, delegation is flat: children cannot spawn grandchildren, and passing `role="orchestrator"` silently degrades to `leaf`. Raise to `2` so orchestrator children can spawn leaf grandchildren; `3` for three-level trees. The agent opts into orchestration per call via `role="orchestrator"`; `orchestrator_enabled: false` forces every child back to leaf regardless. Cost scales multiplicatively — at `max_spawn_depth: 3` with `max_concurrent_children: 3`, the tree can reach 3×3×3 = 27 concurrent leaf agents. See [Subagent Delegation → Depth Limit and Nested Orchestration](features/delegation.md#depth-limit-and-nested-orchestration) for usage patterns.