OpenAI custom provider does not send reasoning from previous turns
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3.3k
- Forks
- 462
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 273
Description
Description
Reasoning is received and persisted correctly for OpenAI-compatible custom providers, but it is not included when assistant messages are converted back into the next Chat Completions request.
For models such as Qwen that expose reasoning via reasoning / reasoning_content, Docker Agent correctly:
- captures the streamed reasoning in
oaistream - accumulates it as
ReasoningContent - stores it on the assistant
chat.Message - displays it in the TUI
However, when the conversation history is converted for the next request, oaistream.ConvertMessages() serializes the assistant content and tool calls but does not serialize msg.ReasoningContent.
As a result, reasoning is visible and stored in the Docker Agent session, but is silently omitted from subsequent model requests.
This means a reasoning model cannot see its previous reasoning after a tool call. In long-running agent workflows this can cause the model to repeatedly reconstruct decisions and analysis it has already performed, substantially increasing reasoning tokens and execution time.
I confirmed this by patching the OpenAI-compatible message conversion to include the stored reasoning. An existing session that Docker Agent previously considered within a ~120K context window immediately produced a ~277K context request once the previously stored reasoning was actually replayed. After compaction/accounting was adjusted, the model retained reasoning correctly across tool turns and showed substantially better continuity.
This appears specific to the OpenAI-compatible/custom-provider conversion path; the reasoning state is already retained and replayed appropriately by other provider implementations.
Expected Behavior
We should at least have an option to preserve reasoning for models using this provider. I appreciate this may need to be configurable rather than enabled by default, since OpenAI-compatible providers can behave differently.
Actual Behavior
Reasoning is never preserved when using OpenAI custom provider.
Steps to Reproduce
Use the custom AI provider and monitor context usage, it will only go up for output and not reasoning.
Docker Agent version
1.141.0
OS & terminal
Linux
Model used
Qwen 3.8 flash next via llama.cpp
Error output
No specific error, its subtle to spot
Screenshots
No response
Additional context
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at oaistream.ConvertMessages() and trace how assistant chat.Message values are converted for the next Chat Completions request. Compare this path with the other provider implementations that already replay reasoning, then determine how the stored ReasoningContent should be preserved for custom providers. Done means subsequent requests retain previous-turn reasoning without changing behavior for providers that do not support it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- ai-infra-agents
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100