Skip to content

Stream silently produces empty response when model outputs non-standard delta.reasoning SSE field (Qwen3 thinking mode) #3145

Description

@philippart-s

Description

When using a Qwen3-family model that streams thinking tokens via a non-standard delta.reasoning SSE field, Docker Agent's stream processor terminates in < 1ms and produces an empty response (tool_calls=0, content_length=0, stopped=true). The agent never executes any tool calls and returns no output.

Expected Behavior

The agent calls list_directory and returns the result.

Actual Behavior

The stream completes in < 1ms with no output:

level=DEBUG msg="OpenAI chat completion stream created successfully" model=Qwen3.5-397B-A17B
level=DEBUG msg="Processing stream" agent=root model=ovhcloud/Qwen3.5-397B-A17B
level=DEBUG msg="Stream processed" agent=root tool_calls=0 content_length=0 stopped=true
level=DEBUG msg="Skipping empty assistant message (no content and no tool calls)" agent=root
level=DEBUG msg="Conversation stopped" agent=root

Steps to Reproduce

Detailed steps to reproduce the bug:

  1. create a reproducer.yml file:
providers:
  ovhcloud:
    api_type: openai_chatcompletions
    base_url: https://oai.endpoints.kepler.ai.cloud.ovh.net/v1
    token_key: OVH_AI_ENDPOINTS_ACCESS_TOKEN

models:
  ovh-qwen:
    provider: ovhcloud
    model: Qwen3.5-397B-A17B
    temperature: 0.6

agents:
  root:
    model: ovh-qwen
    instruction: |
      You are a helpful assistant.
    toolsets:
      - type: filesystem

ℹ️ This is reproducible without an API key, OVHcloud AI Endpoints offers free access to this model at 2 req/s. ℹ️

  1. run docker agent run reproducer.yml "List the files in the current directory"

Environment

  • Docker Agent version: v1.79.0
  • OS: macOS Darwin 25.5.0
  • Provider: api_type: openai_chatcompletions (OVHcloud AI Endpoints)
  • Model: Qwen3.5-397B-A17B

Error Output

level=DEBUG msg="OpenAI chat completion stream created successfully" model=Qwen3.5-397B-A17B
level=DEBUG msg="Processing stream" agent=root model=ovhcloud/Qwen3.5-397B-A17B
level=DEBUG msg="Stream processed" agent=root tool_calls=0 content_length=0 stopped=true
level=DEBUG msg="Skipping empty assistant message (no content and no tool calls)" agent=root
level=DEBUG msg="Conversation stopped" agent=root

Screenshots

N/A

Additional Context

Qwen3-family models in thinking mode stream reasoning tokens via a non-standard delta.reasoning field before producing any content or tool calls:

{"choices":[{"index":0,"delta":{"role":"assistant","reasoning":"The user wants...","name":"assistant"}}]}

Confirmed via curl: the model correctly outputs standard delta.tool_calls eventually, but only after all delta.reasoning chunks are done. Docker Agent's stream processor appears to fail silently on the unknown delta.reasoning field, terminating the stream before any tool calls or content is produced.

The standard delta.tool_calls format produced by the model is correct:
{"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"chatcmpl-tool-xxx","type":"function","function":{"name":"list_directory","arguments":""}}]}}]}

Activity

  1. added theissue type on Jun 16, 2026
  2. added
    area/providers
    area/agent
    on Jun 16, 2026
  3. self-assigned this
    on Jun 17, 2026
  4. added a commit that references this issue on Jun 17, 2026
    d504dd1
  5. philippart-s commented on Jun 25, 2026

    @philippart-s
    Author

    Hi,
    I think the issue is not fixed, with the simple reproducer I have posted, issue is still here with 1.86 version.

    Here is a log analyze (by AI):

    Root cause: cagent ignores reasoning_content in stream deltas from thinking models
    
    Evidence from debug logs across 3 runs:
    
    ┌─────┬──────────────────────────────────────────────────────────────┬─────────────────┬────────────────────────────────┐
    │ Run │                            Config                            │ Stream duration │             Result             │
    ├─────┼──────────────────────────────────────────────────────────────┼─────────────────┼────────────────────────────────┤
    │ 1   │ default                                                      │ <1s             │ content_length=0, tool_calls=0 │
    ├─────┼──────────────────────────────────────────────────────────────┼─────────────────┼────────────────────────────────┤
    │ 2   │ provider_opts: enable_thinking: false (not forwarded to API) │ 42s             │ content_length=0, tool_calls=0 │
    ├─────┼──────────────────────────────────────────────────────────────┼─────────────────┼────────────────────────────────┤
    │ 3   │ /no_think in system prompt                                   │ 8s              │ content_length=0, tool_calls=0 │
    └─────┴──────────────────────────────────────────────────────────────┴─────────────────┴────────────────────────────────┘
    
    Run 1 being instant (<1s) while run 2 takes 42s and run 3 takes 8s proves the model IS generating output — it's thinking. But cagent always logs:
    
    Stream processed agent=root tool_calls=0 content_length=0 stopped=true
    Skipping empty assistant message (no content and no tool calls)
    
    Why: Qwen3 thinking models return their output in reasoning_content in the stream delta, not in content. The content field is empty. cagent's stream processor only reads content and tool_calls, so it sees an empty response and terminates.
    
    Additional evidence: Even the title generation request (max_tokens=20, no tools) returns empty — this is unrelated to tool calling, it's purely the reasoning_content parsing issue.
    
    Fix needed in cagent: The stream processor needs to handle the reasoning_content field in OpenAI-compatible stream deltas, which is the standard field used by Qwen3 and other thinking models (also used by DeepSeek-R1, etc.).
    
    

    And some logs:

    Run 1 — baseline (response in <1s)
    # Request sent correctly with 9 tools
    time=2026-06-25T14:47:18.992 msg="Creating OpenAI chat completion stream" model=Qwen3.5-397B-A17B message_count=3 tool_count=9
    time=2026-06-25T14:47:19.117 msg="OpenAI chat completion stream created successfully" model=Qwen3.5-397B-A17B
    # Instant response → empty
    time=2026-06-25T14:47:19.122 msg="Processing stream" agent=root model=ovhcloud/Qwen3.5-397B-A17B
    time=2026-06-25T14:47:19.132 msg="Stream processed" agent=root tool_calls=0 content_length=0 stopped=true
    time=2026-06-25T14:47:19.132 msg="Skipping empty assistant message (no content and no tool calls)" agent=root
    time=2026-06-25T14:47:19.132 msg="Conversation stopped" agent=root
    
    Run 2 — with provider_opts: enable_thinking: false in YAML (not forwarded to API, response in 42s)
    # Same request, provider_opts not present in actual API payload
    time=2026-06-25T14:53:17.937 msg="Creating OpenAI chat completion stream" model=Qwen3.5-397B-A17B message_count=3 tool_count=9
    time=2026-06-25T14:54:00.094 msg="OpenAI chat completion stream created successfully" model=Qwen3.5-397B-A17B
    # 42s later → still empty
    time=2026-06-25T14:54:00.095 msg="Processing stream" agent=root model=ovhcloud/Qwen3.5-397B-A17B
    time=2026-06-25T14:54:00.099 msg="Stream processed" agent=root tool_calls=0 content_length=0 stopped=true
    time=2026-06-25T14:54:00.099 msg="Skipping empty assistant message (no content and no tool calls)" agent=root
    time=2026-06-25T14:54:00.099 msg="Conversation stopped" agent=root
    
    Run 3 — with /no_think in system prompt (response in 8s)
    # /no_think correctly sent in system message
    time=2026-06-25T14:55:52.142 msg="OpenAI chat completion request" request="...\"content\":\"You are a helpful assistant. /no_think\n\"..."
    time=2026-06-25T14:55:52.140 msg="Creating OpenAI chat completion stream" model=Qwen3.5-397B-A17B message_count=3 tool_count=9
    time=2026-06-25T14:56:00.341 msg="OpenAI chat completion stream created successfully" model=Qwen3.5-397B-A17B
    # 8s later → still empty
    time=2026-06-25T14:56:00.341 msg="Processing stream" agent=root model=ovhcloud/Qwen3.5-397B-A17B
    time=2026-06-25T14:56:00.349 msg="Stream processed" agent=root tool_calls=0 content_length=0 stopped=true
    time=2026-06-25T14:56:00.349 msg="Skipping empty assistant message (no content and no tool calls)" agent=root
    time=2026-06-25T14:56:00.349 msg="Conversation stopped" agent=root
    
  6. aheritier commented on Jun 25, 2026

    @aheritier
    Collaborator

    @Sayt-0 can you check please?

  7. Sayt-0 commented on Jun 25, 2026

    @Sayt-0
    Contributor

    It worked for me when I applied the fix, but np I'll check !

  8. Sayt-0 commented on Jun 25, 2026

    @Sayt-0
    Contributor

    @philippart-s @aheritier

    Dug into this. Breakdown:

    Item Status Why
    reasoning_content dropped on parse Not a bug Adapter reads reasoning_content + reasoning since v1.82+
    Empty title (openai_chatcompletions) Fixed (ours) WithNoThinking() was a no-op for third-party thinking models, so title-gen burned its 20-token budget on reasoning
    Empty main turn (no answer) Not a docker agent bug The model itself returned no content, or the provider didn't send any

    The empty main turn comes from the model/provider, not from docker agent. It happens when:

    • The model produced only reasoning and then stopped with empty content
    • The model got cut off at its token limit (length)
    • The provider rate-limited the request (e.g. OVH free tier = 2 req/min, returns an empty [DONE] stream)

    In all three the response is genuinely empty on the wire, so there's nothing for docker agent to turn into a reply. It now shows a warning instead of stopping silently.

    The fix we did do (title-gen):

    • Sends chat_template_kwargs.enable_thinking=false + floors max_tokens
    • Mirrors what the DMR provider already does
    • Scoped to a custom base_url, never sent to api.openai.com

    Tested with Qwen3 locally:

    • Ran a local Qwen3 (qwen3:4B) via Docker Model Runner end-to-end, and replayed the exact title-gen request against local llama.cpp (returns a non-empty title)
    • Unit tests assert the request body: enable_thinking=false, max_tokens floored, sampling opts kept, nothing injected on a normal turn
    • Caveat: the empty turn didn't repro on this local Qwen3 build, it keeps reasoning in content instead of reasoning_content

    Can open a PR for the title-gen fix if this looks right.

  9. aheritier commented on Jun 26, 2026

    @aheritier
    Collaborator

    @philippart-s do want to have a call to demo the issue on your side ?

  10. philippart-s commented on Jun 26, 2026

    @philippart-s
    Author

    @aheritier Yes, for sure! Shall we discuss it via DM?

  11. added a commit that references this issue on Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/agentarea/providers

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions