{"record":{"id":"064bc12ac7929736","repo":"BerriAI/litellm","slug":"agent-agent-agent-id-requires-x-litellm-trace","errorCode":null,"errorMessage":"Agent '{agent.agent_id}' requires x-litellm-trace-id header on all inbound requests.","messagePattern":"Agent '(.+?)' requires x-litellm-trace-id header on all inbound requests\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/agent_endpoints/a2a_endpoints.py","lineNumber":176,"sourceCode":"\n    agent = global_agent_registry.get_agent_by_id(agent_id=agent_id)\n    if agent is None:\n        agent = global_agent_registry.get_agent_by_name(agent_name=agent_id)\n    return agent\n\n\ndef _enforce_inbound_trace_id(agent: \"AgentResponse\", request: Request) -> None:\n    \"\"\"Raise 400 if agent requires x-litellm-trace-id on inbound calls and it is missing.\"\"\"\n    agent_litellm_params: Final = agent.litellm_params or {}\n    if not agent_litellm_params.get(\"require_trace_id_on_calls_to_agent\"):\n        return\n\n    from litellm.proxy.litellm_pre_call_utils import get_chain_id_from_headers\n\n    headers_dict: Final = dict(request.headers)\n    trace_id: Final = get_chain_id_from_headers(headers_dict)\n    if not trace_id:\n        raise HTTPException(\n            status_code=400,\n            detail=(f\"Agent '{agent.agent_id}' requires x-litellm-trace-id header on all inbound requests.\"),\n        )\n\n\nasync def _forward_jsonrpc(\n    agent_url: str,\n    body: dict[str, object],\n    extra_headers: Mapping[str, str] | None = None,\n) -> dict[str, Any]:\n    from litellm.llms.custom_httpx.http_handler import get_async_httpx_client\n    from litellm.types.llms.custom_http import httpxSpecialProvider\n\n    headers: Final = {\"Content-Type\": \"application/json\", **(extra_headers or {})}\n    handler: Final = get_async_httpx_client(\n        llm_provider=httpxSpecialProvider.A2A,\n        params={\"timeout\": 60.0},\n    )","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/agent_endpoints/a2a_endpoints.py#L158-L194","documentation":"Enforced when the agent's litellm_params set require_trace_id_on_calls_to_agent: every inbound call must carry x-litellm-trace-id so the proxy can correlate traffic; missing header is rejected 400 before dispatch.","triggerScenarios":"Thrown at litellm/proxy/agent_endpoints/a2a_endpoints.py:176 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the x-litellm-trace-id header on requests to this agent."],"exampleFix":"headers['x-litellm-trace-id']=str(uuid4())","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}