Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

feat(agents): add merge_agent_headers utility

Sameer Kankute16a30b55f549
diff --git a/litellm/proxy/agent_endpoints/utils.py b/litellm/proxy/agent_endpoints/utils.py
new file mode 100644
index 00000000000..2b968de54be
--- /dev/null
+++ b/litellm/proxy/agent_endpoints/utils.py
@@ -0,0 +1,27 @@
+"""Utility helpers for A2A agent endpoints."""
+
+from typing import Dict, Mapping, Optional
+
+
+def merge_agent_headers(
+ *,
+ dynamic_headers: Optional[Mapping[str, str]] = None,
+ static_headers: Optional[Mapping[str, str]] = None,
+) -> Optional[Dict[str, str]]:
+ """Merge outbound HTTP headers for A2A agent calls.
+
+ Merge rules:
+ - Start with ``dynamic_headers`` (values extracted from the incoming client request).
+ - Overlay ``static_headers`` (admin-configured per agent).
+
+ If both contain the same key, ``static_headers`` wins.
+ """
+ merged: Dict[str, str] = {}
+
+ if dynamic_headers:
+ merged.update({str(k): str(v) for k, v in dynamic_headers.items()})
+
+ if static_headers:
+ merged.update({str(k): str(v) for k, v in static_headers.items()})
+
+ return merged or None