LiteLlm does not pass the ADK session to a LiteLLM proxy: every call gets its own session_id
Los mantenedores suelen responder en 3 días
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
The issue describes passing invocation_context.session.id through LlmRequest to LiteLlm and includes a linked pull request, #8187. Read that pull request and the LLM flow where adk_agent_name is added to understand the proposed change; the request’s open questions and existing PR mean this work is already underway. Done means the proxy receives the ADK session ID while caller-provided headers are preserved.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🔴 Required Information
Is your feature request related to a specific problem?
LiteLlm does not tell LiteLLM which conversation a call belongs to. Behind a LiteLLM Proxy, the proxy therefore gives every call its own session_id in LiteLLM_SpendLogs, and the calls of one ADK session cannot be grouped (cost per conversation, evaluation, traces).
Measured with a root agent that has one tool and a sub-agent reached through transfer_to_agent, run for 3 turns in a single ADK session with LiteLlm("litellm_proxy/<model>") (LiteLLM 1.105.1, ADK 2.5.0):
| calls | distinct session_id in LiteLLM_SpendLogs |
|
|---|---|---|
| today | 6 | 6 |
with the header x-litellm-session-id: <session.id> |
6 | 1, equal to the ADK session id, sub-agent included |
Describe the Solution You'd Like
When the model is served through a LiteLLM Proxy, LiteLlm sends the ADK session id in the x-litellm-session-id header, which is the header the proxy reads to set the session of a call.
- No header when the request has no session id (calls made outside a Runner), and no header to providers other than the proxy.
- A session id header already set by the caller (
extra_headersat construction, orhttp_options.headers) is kept.
Impact on your work
Without it, per-conversation cost and quality analysis on the proxy side needs a callback copied into every agent. Not blocking, there is a workaround (below).
Willingness to contribute
Yes. A PR with tests is ready and linked below.
🟡 Recommended Information
Describe Alternatives You've Considered
- Workaround today: a
before_model_callback(or a plugin) that setsllm_request.config.http_options.headers["x-litellm-session-id"]from the session. It works, but every app has to know the header and re-implement it. - A label in
config.labels(likeadk_agent_name): the Gemini model sends labels to Vertex, so this would add a very high-cardinality billing label.
Proposed API / Implementation
The model does not see the session today, so the id needs a way to reach it:
class LlmRequest(BaseModel):
session_id: str | None = Field(default=None, exclude=True)
- The LLM flow sets it from
invocation_context.session.id, next to where it adds theadk_agent_namelabel, unless it is already set. exclude=Truekeeps it out ofmodel_dump(), so recorded or traced requests do not change.LiteLlmreads it and adds the header for proxied models.
Open questions:
- Is a field on
LlmRequestthe channel you would want for this? - Should it be on by default (as in the PR), or opt-in?
Additional Context
ADK already adds adk_agent_name to every request so that billing can be sliced per agent. This is the same idea, per session.
- Lenguaje dominante
- Python
- Estrellas
- 22.3k
- Forks
- 4.4k
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de google/adk-python
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
google/adk-python#8360 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
google/adk-python#8359 ·
Los mantenedores suelen responder en 3 días
-
Can pin to litellm version be changed?Posiblemente ocupada @llalitkumarrr la tomó hace 10 días. Abiertomodels
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
google/adk-python#8129 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
OpenAPI tools ignore operation- and path-level server overridesPosiblemente ocupada @sanketpatil06 la tomó hace 14 días. Abiertotools
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
google/adk-python#8064 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
Two docstrings in openapi_tool document parameters the signatures do not acceptPosiblemente ocupada @surajksharma07 la tomó hace 17 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
google/adk-python#8024 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 3 días
Todos los issues de google/adk-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
vllm-project/vllm#70030 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TigreGotico/tugaphone#408 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
gke-labs/kube-agents#7308 ·
Los mantenedores suelen responder en 1 día
-
t: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
chore
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
lugassawan/swe-workbench#841 ·