Skip to content

feat: add opt-in subagent non-convergence guardrail - #68348

Closed
ajzrva-sys wants to merge 1 commit into
NousResearch:mainfrom
ajzrva-sys:feat/cross-turn-progress-tracker
Closed

feat: add opt-in subagent non-convergence guardrail#68348
ajzrva-sys wants to merge 1 commit into
NousResearch:mainfrom
ajzrva-sys:feat/cross-turn-progress-tracker

Conversation

@ajzrva-sys

@ajzrva-sys ajzrva-sys commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Delegated child agents can spend their entire iteration budget making different tool calls without producing user-visible output or landing work. Existing tool_loop_guardrails detects repeated tool-call patterns, but it does not catch this broader non-convergence case.

Related to #414. This circuit breaker complements iteration-budget handling; it does not replace it.

Solution

Add an opt-in non-convergence circuit breaker scoped strictly to delegate_task children.

The tracker evaluates one complete model/tool round at a time:

  • user-visible assistant text counts as progress;
  • a confirmed successful write_file or patch result counts as progress;
  • read-only calls, failed mutations, blocked calls, and cancelled calls do not;
  • warn_after adds convergence guidance to the last tool result;
  • halt_after enters Hermes' existing controlled-halt path and terminates the child loop deterministically.

The feature is disabled by default because a long read-only investigation may be productive even when it has not produced output yet.

Configuration

delegation:
  progress_tracker:
    enabled: false
    warn_after: 15
    halt_after: 25

Changes

  • agent/progress_tracker.py
    • structured none / warn / halt decisions;
    • validated thresholds;
    • explicit per-user-turn reset.
  • agent/agent_init.py
    • tracker initialization only inside delegated-child construction context;
    • disabled configuration installs no runtime tracker.
  • agent/conversation_loop.py and run_agent.py
    • one tracker update per complete tool round;
    • result-aware progress through the existing file-mutation verifier;
    • warning injection and deterministic controlled halt.
  • hermes_cli/config_defaults.py and cli-config.yaml.example
    • opt-in defaults and accurate behavior documentation.
  • Tests cover:
    • parent/child scoping and disabled behavior;
    • turn reset and strict false-like opt-in parsing;
    • successful and failed writes, including decorated successful results;
    • read-only, blocked, and cancelled calls;
    • sequential, concurrent, and segmented execution;
    • structured, withheld, and duplicate interim text;
    • warning durability and real controlled halt.

Validation

65 targeted tests passed
python compileall passed
git diff --check passed

A broader tests/agent tests/run_agent run reached the existing optional-dependency failures in the local minimal test environment (pytest-asyncio and anthropic are not installed); the focused runtime, guardrail, and file-mutation suites pass.

Risk

The heuristic cannot know whether a long read-only investigation is useful. It is therefore delegated-child-only, configurable, and disabled by default.

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have needs-decision Awaiting maintainer decision before any implementation labels Jul 21, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for targeting the distinct case where varied tool calls consume an iteration budget without converging. The premise remains relevant on current main: the loop is budget-bounded at agent/conversation_loop.py:1261, while guardrails reset per turn.

Problems

  • agent/conversation_loop.py:5093 in this PR calls record_file_mutation() from the requested tool name, not a completed result. A failed or blocked write_file/patch, or a non-mutating terminal command, resets the counter. Current main already receives result-aware data in both executor paths at agent/tool_executor.py:1183-1192 and agent/tool_executor.py:1854-1864.
  • The halt_after branch is advisory only: it appends text to a tool result and then continues. Current controlled halts instead set a halt decision and break at agent/conversation_loop.py:6099-6120.
  • tests/agent/test_progress_tracker.py tests only the standalone counter; it does not exercise runtime integration, unsuccessful tools, concurrent/segmented dispatch, or stopping the next iteration.

Suggested changes

  • Feed a tracker from post-execution, result-aware classification and make halt a real loop-exit decision through the existing controlled-halt path.
  • Add integration coverage for sequential, concurrent, segmented, blocked, cancelled, and failed-result paths.

Automated hermes-sweeper review.

Comment thread agent/conversation_loop.py Outdated
Comment thread agent/progress_tracker.py Outdated
@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 30, 2026
@ajzrva-sys ajzrva-sys changed the title feat: add cross-turn progress tracker for non-converging agents feat: add opt-in subagent non-convergence guardrail Jul 30, 2026
@ajzrva-sys
ajzrva-sys force-pushed the feat/cross-turn-progress-tracker branch 2 times, most recently from 63166f0 to d25ea5d Compare August 1, 2026 02:03
@ajzrva-sys

Copy link
Copy Markdown
Contributor Author

CI failures and reviewer feedback addressed in code but PR has gone stale. Closing to rethink approach — will reopen or create a fresh PR when ready.

@ajzrva-sys ajzrva-sys closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants