Anthropic plugin drops thinking blocks between tool calls
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- machine-learning, python
- Área
- ai-infra-agents
Línea de trabajo
Start in livekit-plugins-anthropic by tracing where thinking, redacted_thinking, thinking_delta, and signature_delta events are handled and where FunctionCall.extra is serialized. Use the issue's agent reproduction and request logging to verify that thinking blocks are replayed unchanged before tool results. The change is complete when blocks are restored while the system prompt, tools, and earlier messages are unchanged, but omitted after a prefix change without causing a 400.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug Description
livekit-plugins-anthropic ignores the thinking events in the stream (thinking and redacted_thinking blocks, thinking_delta, signature_delta). The blocks never reach the chat context, so the request that carries a tool result goes without the reasoning that led to the tool call.
The API does not return an error for this. The model silently loses its reasoning and starts again in the middle of a tool loop. Anthropic's docs make this a requirement (Preserving thinking blocks):
Required: within a tool-use turn, pass thinking blocks back.
This now affects agents that never asked for thinking: Claude Haiku 5.5, Sonnet 5.5, Opus 5 and Opus 5.5 think by default (adaptive). #6868 notes the same gap ("thinking blocks are not kept in the chat context, so a turn carrying a tool call is replayed without them") and leaves it out of scope.
Expected Behavior
The thinking blocks of a response that calls a tool go back, unchanged, before that tool_use block in the following requests.
There is one catch for a fix. A thinking block's signature is bound to the system prompt, the tools and the earlier messages. On accounts created on or after 2026-08-31, the API rejects a block with a 400 when that prefix changed, and update_instructions() and update_tools() change it in the middle of a session:
messages.1.content.0: Invalid `signature` in `thinking` block. The block is bound to a different conversation. Remove the block, or set `thinking.block_binding.prefix_mismatch_behavior` to "drop_block". The `system` prompt differs from the one this block was created with.
So a fix must also stop sending a block after its prefix changed.
Reproduction Steps
1. Run an agent with anthropic.LLM(model="claude-haiku-5-5") and one function tool.
2. Ask something that makes the model call the tool.
3. Log the request that carries the tool result: the assistant turn has only the tool_use block.
Direct API check with claude-haiku-5-5 (anthropic 0.125.0, effort low), same tool step:
- tool result, thinking block kept: 200, 601 input tokens
- tool result, thinking block stripped: 200, 525 input tokens (the reasoning is gone, no error)
- block kept, system prompt then edited, with
thinking.block_binding.prefix_mismatch_behavior="error"
(what a new account gets by default): 400 (message above); the same for an added tool
Operating System
macOS 26.6.2
Models Used
Claude Haiku 5.5 (claude-haiku-5-5) through livekit-plugins-anthropic
Package Versions
livekit-agents==1.8.3, and main at ceb3d59
livekit-plugins-anthropic==1.8.3, and main at ceb3d59 (1.8.8 is the same)
anthropic==0.125.0
Proposed fix
A PR follows: it keeps the blocks in FunctionCall.extra["anthropic"] (the field that carries Gemini thought signatures) with a hash of the request prefix, and puts them back only while that prefix is unchanged.
- Lenguaje dominante
- Python
- Estrellas
- 14.6k
- Forks
- 3.9k
- Merge medio
- 3 d 18 h
- PR fusionados (30 d)
- 193
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 livekit/agents
-
Google TTS: default ssml_gender NEUTRAL is rejected for Neural2 voicesPosiblemente ocupada @sarankumar1325 la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Assistant markup is stripped from chat history when expressive mode is offPosiblemente ocupada @ShivamSharma43 la tomó hace 13 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
docs: openai.LLM vs openai.responses.LLM for HTTP OpenAI-compat hostsQuizá libre de nuevo @AbarnaaSree la tomó hace 53 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
livekit/agents#7022 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
google realtime (Gemini Live): manual activity detection — barge-in fires on the model's own generation; unclosed transcript-only generation blocks later generate_replyPosiblemente ocupada @akashhguptaa la tomó hoy. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de livekit/agents
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to itPosiblemente ocupada @anasamin26 la tomó hoy. Abiertobug enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aden-hive/hive#7508 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
llm translation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BerriAI/litellm#47884 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug 🐛
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
netalertx/NetAlertX#1856 · 1 reacción ·
Los mantenedores suelen responder en 1 día