Agent Duplicate Tool-Call Detection
Prevent redundant execution and 'infinite loops' by identifying identical tool requests within a single session.
Steps
- Generate a `call_signature` by hashing the tool name and ordered arguments.
- Maintain a `session_call_stack` to track all unique signatures in the current run.
- Intercept tool calls and compare the new signature against the history.
- Block execution if a signature is identical to a previous call without a state change.
- Inject a 'Duplicate Call Warning' back into the LLM context to force a strategy shift.
- Log the duplicate attempt for debugging agentic loop failures.