OpenAI Chat Completions: tool rounds drop the model's reasoning
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Swift
- Stelle
- 948
- Fork
- 99
- Merge medio
- 18h 38m
- PR unite (30g)
- 56
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di huggingface/AnyLanguageModel
-
OpenAILanguageModel replays tool-call arguments as GeneratedContent's Codable form, not JSONForse già presa @gtokman l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
huggingface/AnyLanguageModel#324 ·
I maintainer di solito rispondono entro 1 giorno
-
Support the Gemini Interactions API in GeminiLanguageModelForse già presa @rizwankce l’ha presa 6 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
huggingface/AnyLanguageModel#302 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
huggingface/AnyLanguageModel#291 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
huggingface/AnyLanguageModel#210 · 5 commenti · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
huggingface/AnyLanguageModel#114 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di huggingface/AnyLanguageModel
Issue simili
-
builtin-port enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cmlarsen/writemorebetter#235 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
callstack/agent-device#3627 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
maziyarpanahi/openmed#4207 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
meshtastic/Meshtastic-Apple#2603 ·
I maintainer di solito rispondono entro 1 giorno