guided_decoding_bugTier 1 · 70% confidence

ai-agents-guided-decoding-bug-using-qwen3-models-with-enable-thinking-false-and--a6878421

agent: ai_agents

When does this happen?

IF Using Qwen3 models with `enable_thinking=False` and guided JSON decoding produces invalid JSON output (extra brackets, markdown fences, or gibberish).

How others solved it

THEN Enable thinking (`enable_thinking=True`) in the chat template kwargs, or remove the reasoning parser entirely. If you must disable thinking, avoid using guided decoding on Qwen3 models until the bug is fixed upstream.

```python
client.chat.completions.create(
    model="Qwen3-30B-A3B",
    messages=[{"role": "user", "content": "Extract keywords as JSON array."}],
    extra_body={
        "guided_json": {"type": "array", "items": {"type": "string"}},
        "chat_template_kwargs": {"enable_thinking": True}  # workaround
    }
)
```

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics