Heuristic:ARCANGEL0 EVA Duplicate Failed Call Prevention
| Knowledge Sources | |
|---|---|
| Domains | Optimization, LLMs |
| Last Updated | 2026-10-29 12:00 GMT |
Overview
Track failed `bash` and `armory_run` tool calls within a turn and block identical retry attempts to prevent the agent from repeating failed commands.
Description
Mitsu tracks failed `bash` and `armory_run` tool invocations within a single agent turn using a `failed_calls` set. Each failed call is keyed by a deterministic identifier derived from the tool name and its arguments (command string for `bash`, tool_id and argv for `armory_run`). If the agent attempts to run an identical command that already failed, the call is intercepted with "Not run: this identical command already failed during this message." This prevents the LLM from entering a retry loop on commands that will fail for the same reason (e.g., missing binary, permission denied, network unreachable).
Usage
Apply this heuristic during agent turn execution. The failed-call tracking is automatic in `run_agent_turn` and persists for the duration of a single turn (reset on each new user message).
The Insight (Rule of Thumb)
- Action: Hash failed `bash` and `armory_run` calls by `["bash", command]` or `["armory_run", tool_id, argv]` and block identical retries.
- Value: Failed calls set is cleared at the start of each new turn.
- Trade-off: The agent cannot retry a command even if conditions change (e.g., after installing a prerequisite), but prevents infinite retry loops.
- Compatibility: Only applies to `bash` and `armory_run` tools. Other tools are not tracked.
Reasoning
LLMs frequently retry failed commands with identical arguments, hoping for a different result. This wastes API tokens, execution time, and can cause repeated side effects on the target. By keying on the exact command content, Mitsu ensures the agent must either modify its approach or abandon the failed path. The per-turn scope ensures that conditions that change between turns (e.g., a tool installed in a previous turn) allow retrying in the next turn.
Code Evidence
Failed call key generation from `agents/runtime.py:128-140`:
def _failed_call_key(name: str, arguments: Any) -> str | None:
local_name = _tool_name(name)
if local_name not in {"bash", "armory_run"} or not isinstance(arguments, dict):
return None
if local_name == "bash":
command = str(arguments.get("command", "")).strip()
return json.dumps([local_name, command], ensure_ascii=False, separators=(",", ":"))
return json.dumps(
[local_name, arguments.get("tool_id"), arguments.get("argv")],
ensure_ascii=False, sort_keys=True, separators=(",", ":"),
)
Duplicate detection from `agents/runtime.py:376-377`:
elif failed_key is not None and failed_key in failed_calls:
result = "Not run: this identical command already failed during this message."
Failed call recording from `agents/runtime.py:407-408`:
if is_error and failed_key is not None:
failed_calls.add(failed_key)