Skip to content

The agent that grows with you

fix: hide inactive grouping options from delegation schema

Tekniumaa83c6d61474
diff --git a/evals/delegation_group_schema/README.md b/evals/delegation_group_schema/README.md
new file mode 100644
index 00000000000..29d0901c79b
--- /dev/null
+++ b/evals/delegation_group_schema/README.md
@@ -0,0 +1,48 @@
+# Delegation grouping schema receipts
+
+`probe.py TREE OUTPUT [--independent]` assembles real eager CLI tool definitions
+in a fresh, credential-free temporary home with networking forbidden. Run it
+in separate interpreters against base and fix with the same arguments.
+Requires `tiktoken` (`o200k_base`); counts use compact OpenAI function JSON.
+This measures schema footprint, not model quality or billed savings.
+
+Base: `b2aa855b626ff8688eb34b95c60ee8b6a4af3679`.
+
+| Policy | Base delegate tokens | Fixed delegate tokens | Change |
+| --- | ---: | ---: | ---: |
+| Default off | 927 | 826 | -101 |
+| Explicit on | 927 | 913 | -14 |
+
+Only `delegate_task` changed in either same-config comparison. Total eager
+CLI schemas were 7586 → 7485 (off), 7586 → 7572 (on). The field remains
+available when enabled; its parameter schema is unchanged. Repeated assembly
+is byte-stable. The two invariants also check static/previous schema immutability,
+legacy task normalization, and grouped/ungrouped delivery partitioning.
+The default-off exposure assertion failed on base before implementation.
+
+## Real-model N=1 child smoke
+
+Pinned to configured Nous `google/gemini-3.7-flash`; no provider fallback.
+A separate temporary home held only copied Nous authentication and minimal
+explicit configuration (no personal skills/memory). One forced parent tool call
+using the real default-off registry schema produced a one-task array without
+`group`. The actual delegation handler then built and ran one real AIAgent child,
+which completed in one API call with `GROUP_GATE_OK`. Parent tool bytes were
+unchanged across child execution. This is a schema-acceptance/execution smoke,
+not a comparative quality evaluation or proof of asynchronous delivery timing.
+
+Before inference, the live catalog was read and an approximately $0.016 budget
+estimated for two calls (20k input + 1024 output allowance).
+
+| Inference | Input | Output | Reasoning (included in output) | API-reported `usage.cost` |
+| --- | ---: | ---: | ---: | ---: |
+| Parent schema call | 796 | 104 | 75 | $0.000987 |
+| Child | 708 | 42 | 37 | $0.0006885 |
+| Total | 1504 | 146 | 112 | $0.0016755 |
+
+Parent request ID: `gen-1788889571-fBLF8eStu3UAevfGtvgD`.
+The raw provider usage exposes the same values as `upstream_inference_cost`;
+these are API-reported costs, not an independently reconciled Portal invoice.
+The child result's local estimator instead reported `$0.000551` with
+`cost_status: estimated`; do not substitute that estimate for the raw receipt.
+Local full receipt: `/tmp/delegation-group-live-receipt.json`.
diff --git a/evals/delegation_group_schema/probe.py b/evals/delegation_group_schema/probe.py
new file mode 100644
index 00000000000..ba79fe54d5f
--- /dev/null
+++ b/evals/delegation_group_schema/probe.py
@@ -0,0 +1,51 @@
+"""Offline same-config schema probe. Run in a fresh interpreter for each tree/policy.
+
+python probe.py /path/to/tree /tmp/receipt.json [--independent]
+Requires tiktoken; no model calls or model-quality claims.
+"""
+
+import json
+import os
+from pathlib import Path
+import socket
+import sys
+import tempfile
+
+root, destination = sys.argv[1:3]
+sys.path.insert(0, root)
+os.chdir(root)
+with tempfile.TemporaryDirectory(prefix="delegate-schema-") as home:
+ os.environ.clear()
+ os.environ.update(HOME=home, HERMES_HOME=home, PATH="/usr/bin:/bin", HERMES_PLATFORM="cli")
+ config = {"tools": {"tool_search": {"defer": []}}}
+ if "--independent" in sys.argv:
+ config["delegation"] = {"independent_completions": True}
+ Path(home, "config.yaml").write_text(json.dumps(config), encoding="utf-8")
+
+ def deny_network(*args, **kwargs):
+ raise RuntimeError("Offline schema probe forbids network access")
+
+ socket.socket.connect = deny_network
+ import tiktoken
+ from model_tools import get_tool_definitions
+
+ encoder = tiktoken.get_encoding("o200k_base")
+ definitions = get_tool_definitions(enabled_toolsets=["hermes-cli"], quiet_mode=True)
+ serialized = json.dumps(definitions, separators=(",", ":"))
+ repeated = get_tool_definitions(enabled_toolsets=["hermes-cli"], quiet_mode=True)
+ assert json.dumps(repeated, separators=(",", ":")) == serialized
+ counts = {
+ definition["function"]["name"]: len(encoder.encode(json.dumps(definition, separators=(",", ":"))))
+ for definition in definitions
+ }
+ delegate = next(d for d in definitions if d["function"]["name"] == "delegate_task")
+ receipt = {
+ "config": config,
+ "tokens": counts,
+ "total_tokens": sum(counts.values()),
+ "delegate": delegate,
+ "repeated_assembly_byte_stable": True,
+ "model_calls": 0,
+ }
+ Path(destination).write_text(json.dumps(receipt, indent=2), encoding="utf-8")
+ print(json.dumps({"destination": destination, "total_tokens": receipt["total_tokens"], "delegate_tokens": counts["delegate_task"]}))
diff --git a/tests/tools/test_delegate_group_schema.py b/tests/tools/test_delegate_group_schema.py
new file mode 100644
index 00000000000..c625446f794
--- /dev/null
+++ b/tests/tools/test_delegate_group_schema.py
@@ -0,0 +1,47 @@
+"""Grouping is advertised only when the delivery policy consumes it."""
+
+import json
+from dataclasses import fields
+
+from tools.delegate_tool import DELEGATE_TASK_SCHEMA, _strip_model_hidden_task_fields
+from tools.delegate_tool_dispatch import _Batch, _units_of
+from tools.delegate_tool_tasks import _normalize_task_list
+from tools.registry import registry
+
+
+def test_group_schema_tracks_delivery_policy_without_mutating_previous_definitions(monkeypatch):
+ from tools import delegate_tool_config
+
+ original = json.dumps(DELEGATE_TASK_SCHEMA)
+ snapshots = []
+ for config in ({}, {"independent_completions": True}, {"independent_completions": False}):
+ monkeypatch.setattr(delegate_tool_config, "_cfg", lambda: config)
+ definition = registry.get_definitions({"delegate_task"})[0]
+ enabled = config.get("independent_completions", False)
+ task = definition["function"]["parameters"]["properties"]["tasks"]["items"]
+ assert ("group" in task["properties"]) == enabled
+ assert ("group" in definition["function"]["description"]) == enabled
+ assert json.dumps(registry.get_definitions({"delegate_task"})[0]) == json.dumps(definition)
+ for previous, serialized in snapshots:
+ assert json.dumps(previous) == serialized
+ snapshots.append((definition, json.dumps(definition)))
+ assert json.dumps(DELEGATE_TASK_SCHEMA) == original
+
+
+def test_legacy_group_replay_remains_accepted_and_delivery_policy_controls_units(monkeypatch):
+ from tools import delegate_tool_config
+
+ tasks = [{"goal": "Review first module", "group": "join"}, {"goal": "Review second module", "group": "join"}, {"goal": "Review third module"}]
+ assert _strip_model_hidden_task_fields(tasks) is tasks
+ normalized, error = _normalize_task_list(None, None, tasks, None, "leaf", 3)
+ assert error is None and normalized == tasks
+ batch = _Batch(**{field.name: None for field in fields(_Batch)})
+ batch.children = [(i, task, None) for i, task in enumerate(tasks)]
+ for enabled in (False, True):
+ monkeypatch.setattr(delegate_tool_config, "_cfg", lambda: {"independent_completions": enabled})
+ units = _units_of(batch)
+ if enabled:
+ assert [[i for i, _, _ in unit.children] for unit in units] == [[0, 1], [2]]
+ assert [unit.group for unit in units] == ["join", None]
+ else:
+ assert units == [batch]
diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py
index 4fe93157783..6e23f2c799f 100644
--- a/tools/delegate_tool.py
+++ b/tools/delegate_tool.py
@@ -498,7 +498,7 @@ def delegate_task(
# ── OpenAI function-calling schema ──────────────────────────────────────────
-def _build_top_level_description() -> str:
+def _build_top_level_description(*, independent_completions=None) -> str:
"""delegate_task description: ONLY guidance stated nowhere else in the schema
(limits live in the 'tasks' parameter description, rebuilt per get_definitions())."""
try:
@@ -515,15 +515,22 @@ def _build_top_level_description() -> str:
)
else:
restrictions_rule = "- Children cannot call delegate_task, clarify, memory, or cronjob.\n"
- return _DESCRIPTION_HEAD + restrictions_rule + _DESCRIPTION_TAIL
+ from tools.delegate_tool_config import _get_independent_completions
+
+ if independent_completions is None:
+ independent_completions = _get_independent_completions()
+ delivery = (
+ "each ungrouped task / `group` returns on its own"
+ if independent_completions else "one message per call"
+ )
+ return _DESCRIPTION_HEAD.format(delivery=delivery) + restrictions_rule + _DESCRIPTION_TAIL
_DESCRIPTION_HEAD = (
"Spawn subagents in isolated contexts; each gets its own conversation, terminal session, and toolset, and only its "
"final summary returns to you. Pass every task in `tasks` — one entry spawns one subagent, several run in parallel "
"(limit in the tasks description).\n\n"
"Runs in the background: dispatch returns immediately with live transcript paths, and the call's results re-enter "
- "the conversation as a new message when its subagents finish (one message per call by default; with "
- "delegation.independent_completions each ungrouped task / `group` returns on its own). Results are delivered only "
+ "the conversation as a new message when its subagents finish ({delivery}). Results are delivered only "
"BETWEEN your turns: finish whatever does not depend on them, then give a one-line status and END YOUR TURN. Never "
"wait or poll on transcripts, artifact files, or CI for a child. "
"While children run, `action` (list/steer/stop) controls them live — steer when a transcript shows a "
@@ -564,12 +571,24 @@ def _build_tasks_param_description() -> str:
def _build_dynamic_schema_overrides() -> dict:
"""Per-call schema overrides (ToolEntry.dynamic_schema_overrides): every
get_definitions() pass rewrites the descriptions to the user's actual limits."""
+ from tools.delegate_tool_config import _get_independent_completions
+
+ independent_completions = _get_independent_completions()
overrides_params = {**DELEGATE_TASK_SCHEMA["parameters"]}
# Copy properties so the static schema dict is never mutated.
overrides_params["properties"] = {k: dict(v) for k, v in DELEGATE_TASK_SCHEMA["parameters"]["properties"].items()}
overrides_params["properties"]["tasks"]["description"] = _build_tasks_param_description()
- return {"description": _build_top_level_description(), "parameters": overrides_params}
+ if not independent_completions:
+ tasks = overrides_params["properties"]["tasks"]
+ tasks["items"] = {**tasks["items"], "properties": {
+ k: v for k, v in tasks["items"]["properties"].items() if k != "group"
+ }}
+
+ return {
+ "description": _build_top_level_description(independent_completions=independent_completions),
+ "parameters": overrides_params,
+ }
def _p(type_: str, description: str, **extra) -> dict:
return {"type": type_, **extra, "description": description}
diff --git a/website/docs/user-guide/features/delegation.md b/website/docs/user-guide/features/delegation.md
index 607d7bd9bfd..3d2c49bd66a 100644
--- a/website/docs/user-guide/features/delegation.md
+++ b/website/docs/user-guide/features/delegation.md
@@ -165,7 +165,9 @@ When a top-level agent provides a `tasks` array, Hermes returns one background h
### Independent completions (opt-in)
-Set `delegation.independent_completions: true` to have results land **per completion unit** as each finishes instead:
+Set `delegation.independent_completions: true` to have results land **per completion unit** as each finishes instead. The model-facing `group` field and grouping guidance are only advertised when this option is enabled. Start a new session after changing it so the tool schema can reflect the setting without changing an existing conversation's cached prefix. Old calls containing `group` remain accepted; with the option off, the whole call still returns together.
+
+When independent completions are enabled:
- Omit `group` when each result is useful to act on separately. Each task reports as soon as it finishes.
- Use the same `group` string when you want to review outputs together: comparison, synthesis, or one coordinated decision. The group returns **one** consolidated message after all its tasks finish. Even independently executable tasks can belong in one group when their results inform the same decision.