BerriAI/litellm · error · ValueError

Agentic loop detected repeated tool-call fingerprint…

Error message

Agentic loop detected repeated tool-call fingerprint; aborting rerun

What it means

Agentic-loop safety check computed a canonical fingerprint of the model's tool calls and found it identical to one seen earlier in the loop — the model is re-issuing the exact same tool call instead of progressing, so the rerun is aborted to prevent an infinite loop.

Solutions

  1. The agent is stuck repeating the same tool call; change the prompt or tool outputs so the model makes progress.
  2. Increase diversity of tool results or lower max_agentic_loops to fail fast.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/chat_completion_agentic_loop.py:77 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5e816cf300fbb69a. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/chat_completion_agentic_loop.py:77


def _fingerprint_tools(tool_calls: object) -> str:
    try:
        return json.dumps(tool_calls, sort_keys=True, default=str)
    except Exception:
        return str(tool_calls)


def _check_agentic_loop_safety(
    tool_calls: object,
    fingerprints: list[str],
    depth: int,
    max_loops: int,
    model: str,
) -> str:
    fingerprint: Final = _fingerprint_tools(tool_calls)
    if fingerprint in fingerprints:
        raise ValueError("Agentic loop detected repeated tool-call fingerprint; aborting rerun")
    if depth >= max_loops:
        raise ValueError(f"Exceeded max_agentic_loops={max_loops} for model={model}")
    return fingerprint


def _wrap_response_as_fake_stream(response: object) -> object:
    if getattr(response, "object", None) == "chat.completion.chunk":
        return response
    if not hasattr(response, "choices"):
        return response
    from litellm.llms.base_llm.base_model_iterator import (
        convert_model_response_to_streaming,
    )

    return convert_model_response_to_streaming(cast(ModelResponse, response))


def _add_agentic_loop_metadata(kwargs_for_followup: dict[str, object]) -> None:

View on GitHub (pinned to 77b7c6c40c)