BerriAI/litellm · error · ValueError

WebSearchInterception: missing follow-up messages

Error message

WebSearchInterception: missing follow-up messages

What it means

The legacy websearch-interception follow-up path reached its completion call without the follow-up messages it needs to continue the conversation after executing searches — an internal invariant break in request assembly, not a user input error.

Solutions

  1. Ensure the web-search response is followed by a request containing follow-up messages so the interception handler can continue.

Example fix

# include the original messages array in the intercepted request payload
Defensive patterns

Strategy: validation

When it happens

Trigger: The web search interception handler receives a request lacking follow-up messages.

Common situations: Upstream client sending a search-only payload without conversation messages.


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

Appendix: source

Thrown at litellm/integrations/websearch_interception/handler.py:1188

        tool_calls: list[dict],
        thinking_blocks: list[dict],
        anthropic_messages_optional_request_params: dict,
        logging_obj: "LiteLLMLoggingObj | None",
        stream: bool,
        kwargs: dict,
    ) -> "AnthropicMessagesResponse | AsyncIterator[object]":
        """Legacy path: execute search + build patch + run follow-up call."""
        request_patch, structured_results = await self._build_anthropic_request_patch(
            model=model,
            messages=messages,
            tool_calls=tool_calls,
            thinking_blocks=thinking_blocks,
            anthropic_messages_optional_request_params=anthropic_messages_optional_request_params,
            logging_obj=logging_obj,
            kwargs=kwargs,
        )
        if request_patch.messages is None:
            raise ValueError("WebSearchInterception: missing follow-up messages")

        optional_params: Final = dict(anthropic_messages_optional_request_params)
        optional_params.update(request_patch.optional_params)
        max_tokens = request_patch.max_tokens
        if max_tokens is None:
            max_tokens = cast(int | None, optional_params.pop("max_tokens", None))
        else:
            optional_params.pop("max_tokens", None)
        if max_tokens is None:
            max_tokens = cast(int, kwargs.get("max_tokens", 1024))

        response: AnthropicMessagesResponse | AsyncIterator[object] = await anthropic_messages.acreate(
            max_tokens=max_tokens,
            messages=request_patch.messages,
            model=request_patch.model or model,
            **optional_params,
            **request_patch.kwargs,
        )

View on GitHub (pinned to 77b7c6c40c)