mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(delegate): remove model-facing max_iterations override; config is authoritative (#14732)
Previously delegate_task exposed 'max_iterations' in its JSON schema and used `max_iterations or default_max_iter` — so a model guessing conservatively (or copy-pasting a docstring hint like 'Only set lower for simple tasks') could silently shrink a subagent's budget below the user's configured delegation.max_iterations. One such call this session capped a deep forensic audit at 40 iterations while the user's config was set to 250. Changes: - Drop 'max_iterations' from DELEGATE_TASK_SCHEMA['parameters']['properties']. Models can no longer emit it. - In delegate_task(): ignore any caller-supplied max_iterations, always use delegation.max_iterations from config. Log at debug if a stale schema or internal caller still passes one through. - Keep the Python kwarg on the function signature for internal callers (_build_child_agent tests pass it through the plumbing layer). - Update test_schema_valid to assert the param is now absent (intentional contract change, not a change-detector).
This commit is contained in:
parent
b5333abc30
commit
64e6165686
2 changed files with 16 additions and 9 deletions
|
|
@ -1558,7 +1558,18 @@ def delegate_task(
|
|||
# Load config
|
||||
cfg = _load_config()
|
||||
default_max_iter = cfg.get("max_iterations", DEFAULT_MAX_ITERATIONS)
|
||||
effective_max_iter = max_iterations or default_max_iter
|
||||
# Model-supplied max_iterations is ignored — the config value is authoritative
|
||||
# so users get predictable budgets. The kwarg is retained for internal callers
|
||||
# and tests; a model-emitted value here would only shrink the budget and
|
||||
# surprise the user mid-run. Log and drop it if one slips through from a
|
||||
# cached tool schema or a stale provider.
|
||||
if max_iterations is not None and max_iterations != default_max_iter:
|
||||
logger.debug(
|
||||
"delegate_task: ignoring caller-supplied max_iterations=%s; "
|
||||
"using delegation.max_iterations=%s from config",
|
||||
max_iterations, default_max_iter,
|
||||
)
|
||||
effective_max_iter = default_max_iter
|
||||
|
||||
# Resolve delegation credentials (provider:model pair).
|
||||
# When delegation.provider is configured, this resolves the full credential
|
||||
|
|
@ -2098,13 +2109,6 @@ DELEGATE_TASK_SCHEMA = {
|
|||
"When provided, top-level goal/context/toolsets are ignored."
|
||||
),
|
||||
},
|
||||
"max_iterations": {
|
||||
"type": "integer",
|
||||
"description": (
|
||||
"Max tool-calling turns per subagent (default: 50). "
|
||||
"Only set lower for simple tasks."
|
||||
),
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"enum": ["leaf", "orchestrator"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue