BerriAI/litellm · error · ValueError

request is required

Error message

request is required

What it means

In the standard (non-bridge) flow of asend_message, request is the message payload; calling with request=None raises this ValueError immediately, before any client or card work. It is a fail-fast guard against no-op invocations with a clearer message than a downstream AttributeError would be.

Solutions

  1. Build and pass an a2a.types.SendMessageRequest with MessageSendParams
  2. Assert request is not None before calling when it is built conditionally

Example fix

# before
await asend_message(api_base='http://agent:10001')  # no request

# after
req = SendMessageRequest(id=str(uuid4()), params=MessageSendParams(message=my_message))
await asend_message(request=req, api_base='http://agent:10001')
Defensive patterns

Strategy: validation

Validate before calling

if request is None:
    raise ValueError(
        'asend_message requires request=SendMessageRequest(...) — none was built'
    )
resp = await asend_message(request=request, api_base=api_base)

Try / catch

try:
    resp = await asend_message(api_base=api_base, request=request)
except ValueError as e:
    if e.args[0] == 'request is required':
        request = build_request(...)  # construct and retry once
        resp = await asend_message(api_base=api_base, request=request)
    else:
        raise

Prevention

When it happens

Trigger: Calling asend_message(api_base=..., ...) but forgetting request; passing message data as loose kwargs instead of a SendMessageRequest; conditionally-built request ending up None.

Common situations: First attempts with the A2A API assuming openai-style 'messages' kwargs; refactors where request construction was moved behind a flag that is off.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at litellm/a2a_protocol/main.py:459

    logging_obj: Final = kwargs.get("litellm_logging_obj")
    trace_id = getattr(logging_obj, "litellm_trace_id", None) if logging_obj else None
    custom_llm_provider: Final = litellm_params.get("custom_llm_provider")

    # Route through completion bridge if custom_llm_provider is set
    if custom_llm_provider:
        if request is None:
            raise ValueError("request is required for completion bridge")
        return await _send_message_via_completion_bridge(
            request=request,
            custom_llm_provider=custom_llm_provider,
            api_base=api_base,
            litellm_params=litellm_params,
            agent_extra_headers=agent_extra_headers,
        )

    # Standard A2A client flow
    if request is None:
        raise ValueError("request is required")

    # Create A2A client if not provided but api_base is available
    if a2a_client is None:
        if api_base is None:
            raise ValueError("Either a2a_client or api_base is required for standard A2A flow")
        trace_id = trace_id or str(uuid.uuid4())
        extra_headers: Final[dict[str, str]] = {"X-LiteLLM-Trace-Id": trace_id}
        if agent_id:
            extra_headers["X-LiteLLM-Agent-Id"] = agent_id
        # Overlay agent-level headers (agent headers take precedence over LiteLLM internal ones)
        if agent_extra_headers:
            extra_headers.update(agent_extra_headers)
        a2a_client = await create_a2a_client(base_url=api_base, extra_headers=extra_headers)

    # Type assertion: a2a_client is guaranteed to be non-None here
    assert a2a_client is not None

    agent_name: Final = _get_a2a_model_info(a2a_client, kwargs)

View on GitHub (pinned to 77b7c6c40c)