{"record":{"id":"e7fe5f6ee229c9e2","repo":"BerriAI/litellm","slug":"request-is-required","errorCode":null,"errorMessage":"request is required","messagePattern":"request is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/a2a_protocol/main.py","lineNumber":459,"sourceCode":"    logging_obj: Final = kwargs.get(\"litellm_logging_obj\")\n    trace_id = getattr(logging_obj, \"litellm_trace_id\", None) if logging_obj else None\n    custom_llm_provider: Final = litellm_params.get(\"custom_llm_provider\")\n\n    # Route through completion bridge if custom_llm_provider is set\n    if custom_llm_provider:\n        if request is None:\n            raise ValueError(\"request is required for completion bridge\")\n        return await _send_message_via_completion_bridge(\n            request=request,\n            custom_llm_provider=custom_llm_provider,\n            api_base=api_base,\n            litellm_params=litellm_params,\n            agent_extra_headers=agent_extra_headers,\n        )\n\n    # Standard A2A client flow\n    if request is None:\n        raise ValueError(\"request is required\")\n\n    # Create A2A client if not provided but api_base is available\n    if a2a_client is None:\n        if api_base is None:\n            raise ValueError(\"Either a2a_client or api_base is required for standard A2A flow\")\n        trace_id = trace_id or str(uuid.uuid4())\n        extra_headers: Final[dict[str, str]] = {\"X-LiteLLM-Trace-Id\": trace_id}\n        if agent_id:\n            extra_headers[\"X-LiteLLM-Agent-Id\"] = agent_id\n        # Overlay agent-level headers (agent headers take precedence over LiteLLM internal ones)\n        if agent_extra_headers:\n            extra_headers.update(agent_extra_headers)\n        a2a_client = await create_a2a_client(base_url=api_base, extra_headers=extra_headers)\n\n    # Type assertion: a2a_client is guaranteed to be non-None here\n    assert a2a_client is not None\n\n    agent_name: Final = _get_a2a_model_info(a2a_client, kwargs)","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/a2a_protocol/main.py#L441-L477","documentation":"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.","triggerScenarios":"Calling asend_message(api_base=..., ...) but forgetting request; passing message data as loose kwargs instead of a SendMessageRequest; conditionally-built request ending up None.","commonSituations":"First attempts with the A2A API assuming openai-style 'messages' kwargs; refactors where request construction was moved behind a flag that is off.","solutions":["Build and pass an a2a.types.SendMessageRequest with MessageSendParams","Assert request is not None before calling when it is built conditionally"],"exampleFix":"# before\nawait asend_message(api_base='http://agent:10001')  # no request\n\n# after\nreq = SendMessageRequest(id=str(uuid4()), params=MessageSendParams(message=my_message))\nawait asend_message(request=req, api_base='http://agent:10001')","handlingStrategy":"validation","validationCode":"if request is None:\n    raise ValueError(\n        'asend_message requires request=SendMessageRequest(...) — none was built'\n    )\nresp = await asend_message(request=request, api_base=api_base)","typeGuard":null,"tryCatchPattern":"try:\n    resp = await asend_message(api_base=api_base, request=request)\nexcept ValueError as e:\n    if e.args[0] == 'request is required':\n        request = build_request(...)  # construct and retry once\n        resp = await asend_message(api_base=api_base, request=request)\n    else:\n        raise","preventionTips":["Never call asend_message without a constructed request object","Make request construction unconditional (fail at build time with a clear error)","Type your call sites: request: SendMessageRequest, not Optional"],"tags":["a2a","validation","parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}