OpenAI Chat Completions: tool rounds drop the model's reasoning
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 50/100
Línea de trabajo
Start in the Chat Completions tool loop of OpenAILanguageModel, where the next request's assistant message is rebuilt from content and tool calls only. Check the reference fork commit (gtokman/AnyLanguageModel@daf184b) for the nonstreaming change, then decide whether to store reasoning as Transcript.Reasoning entries as PR #290 does for Anthropic. Done means that a DeepSeek or gateway tool round sends back reasoning_content, reasoning and reasoning_details unchanged, with a test that inspects the request body.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
OpenAILanguageModel's Chat Completions tool loop drops the model's reasoning between tool rounds. Thinking models return it alongside their tool calls, in reasoning_content (DeepSeek's API) or reasoning and reasoning_details (OpenRouter, Vercel AI Gateway). The next request in the same response rebuilds the assistant message from the content and tool calls only, so the reasoning that planned those calls is lost.
Why it matters
- DeepSeek requires it. Its thinking mode docs say
reasoning_contentmust be passed back on tool-call turns, and its API returns 400 when it isn't. Other clients have hit this: NousResearch/hermes-agent#17400, langchain-ai/langchain#39370, Kilo-Org/kilocode#9501. - Through a gateway it fails silently. The Vercel AI Gateway accepts the requests, so nothing errors. But each round, the model sees its earlier tool calls without the reasoning behind them.
Reproduction
Run a session with tools against deepseek/deepseek-v4.1-flash-fast or zai/glm-5.3-fast on the Vercel AI Gateway (https://ai-gateway.vercel.sh/v1), and record the request bodies. Each response's choices[0].message has reasoning and reasoning_details next to tool_calls. In the next request, the matching assistant message has only content and tool_calls. Across one 8-round response, 0 of the 8 assistant messages carried the reasoning back.
PR #290 added reasoning transcript entries and replay for Anthropic. Chat Completions doesn't read or send these fields yet (checked on main at 80d50b0).
A possible fix
In the tool loop, decode the three fields from the response message and send them back unchanged on that round's assistant message. Keeping them within the one response matches DeepSeek's rule, so the transcript doesn't need to change. I did this for the nonstreaming loop in a fork, with a test: gtokman/AnyLanguageModel@daf184b. The commit is on 0.16.0. The streaming loop would need the same change, gathering the reasoning deltas.
A fuller version would store the reasoning as Transcript.Reasoning entries, as #290 does for Anthropic, so it could also be replayed after a transcript is restored. I'm happy to open a PR for either approach.
- Lenguaje dominante
- Swift
- Estrellas
- 948
- Forks
- 99
- Merge medio
- 19 h 50 min
- PR fusionados (30 d)
- 51
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 huggingface/AnyLanguageModel
-
OpenAILanguageModel replays tool-call arguments as GeneratedContent's Codable form, not JSONPosiblemente ocupada @gtokman la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
huggingface/AnyLanguageModel#324 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
huggingface/AnyLanguageModel#328 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
huggingface/AnyLanguageModel#327 ·
Los mantenedores suelen responder en 1 día
-
Support the Gemini Interactions API in GeminiLanguageModelQuizá libre de nuevo @rizwankce la tomó hace 9 días y no hay ningún pull request abierto. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
huggingface/AnyLanguageModel#302 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
huggingface/AnyLanguageModel#291 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de huggingface/AnyLanguageModel
Issues similares
-
agent/quality help wanted origin/quality quality stage/010-actionable testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
hivecommons/hotshot#227 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
cucumberswift/CucumberSwift#437 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Ace: adopt desktopToolRules()Abiertoace documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
githubnext/desktop-tools#104 ·
Los mantenedores suelen responder en 1 día
-
Bug MapKit SwiftUI
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
vdhamer/Photo-Club-Hub#885 · 1 comentario ·