BerriAI/litellm · error · ValueError

Agentic loop plan missing patched messages

Error message

Agentic loop plan missing patched messages

What it means

Error "Agentic loop plan missing patched messages" thrown in BerriAI/litellm.

Source

Thrown at litellm/litellm_core_utils/chat_completion_agentic_loop.py:131

async def _execute_chat_completion_agentic_plan(
    *,
    plan: AgenticLoopPlan,
    callback: CustomLogger,
    model: str,
    optional_params: dict[str, object],
    kwargs: dict[str, object],
    logging_obj: object,
    custom_llm_provider: str,
    depth: int,
    max_loops: int,
    fingerprints: list[str],
    fingerprint: str,
) -> object:
    import litellm

    patch: Final = plan.request_patch or AgenticLoopRequestPatch()
    if patch.messages is None:
        raise ValueError("Agentic loop plan missing patched messages")

    full_model_name = patch.model or model
    if "/" not in full_model_name:
        full_model_name = f"{custom_llm_provider}/{full_model_name}"

    optional_params_for_followup: Final = {**optional_params, **patch.optional_params}
    if patch.tools is not None:
        optional_params_for_followup["tools"] = patch.tools
    if "tool_choice" not in patch.optional_params:
        optional_params_for_followup.pop("tool_choice", None)

    kwargs_for_followup: Final = _filter_followup_kwargs(kwargs)
    kwargs_for_followup.update(
        {k: v for k, v in _filter_followup_kwargs(patch.kwargs).items() if k not in optional_params_for_followup}
    )
    kwargs_for_followup["_agentic_loop_depth"] = depth + 1
    kwargs_for_followup["max_agentic_loops"] = max_loops
    kwargs_for_followup["_agentic_loop_fingerprints"] = fingerprints + [fingerprint]

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Internal agentic loop state error; retry the request or report with the plan payload.

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/f401b071810132eb. Report an issue: GitHub.