Skip to content

Add lightweight runner guards for repeated failure thrashing#279

Open
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/implement-runner-fixes-to-reduce-thrashing
Open

Add lightweight runner guards for repeated failure thrashing#279
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/implement-runner-fixes-to-reduce-thrashing

Conversation

@mmprotest

Copy link
Copy Markdown
Owner

Motivation

  • Reduce obvious thrashing where the agent repeatedly issues the same failing mutation or brittle shell form without adding determinism or a heavy recovery subsystem.
  • Keep interventions minimal, visible in existing events/transcripts, and reversible after one simple grounding step.
  • Preserve exploratory behavior and avoid task-specific heuristics or planner-style logic.

Description

  • Added a tiny rolling failure memory and transient guard state on Runner: _recent_failed_actions, _recent_failed_shell_forms, _surface_grounding_block, _shell_retry_block_form, and related pending message fields to hold short-window failure history. (files: villani_code/state.py)
  • Implemented compact helpers for normalization/classification: _normalize_failure_reason, _failure_kind, _shell_failure_from_result, _normalize_shell_command, _is_brittle_shell_command, _is_grounding_action, _record_failure_and_update_guards, and _check_transient_action_guards, enforcing the exact trigger rules in the last-3/last-5 windows. (file: villani_code/state.py)
  • Injected a single short recovery message into the next tool-result turn when triggers fire and require one grounding action (read/inspect or non-mutating shell) before allowing the same mutation surface again; the pending message is cleared after being attached to the next user tool-result payload. (file: villani_code/state.py)
  • Added a lightweight pre-policy guard hook in execute_tool_with_policy to detect and block transient guarded actions (including brittle near-duplicate shell retries), emit a transient_action_guard_blocked event, and return an explicit short block message as a normal tool error. (file: villani_code/state_tooling.py)
  • Added focused tests exercising the new guards and clearing behavior in tests/test_loop.py. (file: tests/test_loop.py)

Testing

  • Added unit tests in tests/test_loop.py covering: repeated tool failures triggering a regrounding intervention and temporary mutation block, grounding clearing the block, near-duplicate brittle shell retry blocking and clearing, and that isolated single failures do not trigger guards.
  • Ran the focused test selection with: pytest -q tests/test_loop.py -k 'failure_loop_guard_blocks_mutation_until_grounding or brittle_near_duplicate_shell_retry_guard_and_clear or single_failures_do_not_trigger_thrash_guards', which passed with 3 passed, 25 deselected.
  • All modified tests in the focused run succeeded.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant