BerriAI/litellm · error · ValueError
Agentic loop plan missing patched messages
Error message
Agentic loop plan missing patched messages
What it means
Internal invariant in the agentic-loop executor: the plan's request_patch carries no patched messages, so there is nothing to send on the follow-up completion call — the plan was constructed incompletely.
Solutions
- This is an internal error: the agentic loop produced a plan without patched messages. Re-run with verbose logging and report the bug.
- Avoid modifying messages mid-loop via callbacks that strip message content.
Defensive patterns
Strategy: validation
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@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/f401b071810132eb.
Report an issue: GitHub.
Appendix: 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 77b7c6c40c)