MoonshotAI / MoonshotAI/kimi-cli
kosong: OpenAILegacy emits reasoning_effort: null for thinking "off" — invalid for strict APIs and does not disable reasoning
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Summary
kosong 0.53.0's OpenAILegacy provider puts "reasoning_effort": null on the
wire when thinking effort is off. This is wrong in two ways: null is not a
valid value in the OpenAI chat-completions schema (it must be an enum string, or
the field absent), and it does not actually disable reasoning. Lenient backends
(e.g. Ollama Cloud) accept null but treat it as "reasoning on by default", so
thinking stays enabled; strict validators (e.g. Synthetic.new, TypeBox) reject
it with HTTP 400, which then drives a retry/rate-limit loop.
Root cause
chat_provider/openai_common.py→thinking_effort_to_reasoning_effort("off")
returns PythonNone(line ~120).contrib/chat_provider/openai_legacy.py::generate()sets
reasoning_effort = self._reasoning_effort(~129) and passes
reasoning_effort=reasoning_efforttoclient.chat.completions.create()
(~148). The OpenAI SDK serializes an explicitNoneasnull; only the
omit/Omitsentinel is dropped from the payload.- The auto-enable guard at ~134 only handles
Omit, so aNonefrom
with_thinking("off")(~167) flows straight through.
Steps to reproduce
provider.with_thinking("off")on anOpenAILegacyprovider.generate(...)against a strict OpenAI-compatible endpoint.- Outgoing body contains
"reasoning_effort": null→ HTTP 400 on strict
validators. Wire check:
curl .../v1/chat/completions -d '{"model":"...","messages":[...],"reasoning_effort":null}'
returnsnull is not equal to none/low/medium/high...(TypeBox), while a
valid string succeeds.
Expected behavior
off should send a valid value that actually disables reasoning, not null.
Suggested fix
Map off to the string "none" in thinking_effort_to_reasoning_effort
instead of None. "none" is a valid enum value, passes strict validators, and
disables thinking on backends that honor it (Ollama Cloud, Synthetic/TypeBox).
Caveat: a few OpenAI-compatible backends reject "none" (e.g. Fireworks wants
"low"), and native OpenAI only added "none" for gpt-5.1+. A provider-aware
mapping or a configurable off-value fallback may be warranted. Can send a PR.
Environment
- kosong 0.53.0 (confirmed on
main,packages/kosong) - Endpoints observed: Ollama Cloud (accepts
null, reasoning stays on),
Synthetic.new (400)
Contributor guide
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 in chat_provider/openai_common.py at thinking_effort_to_reasoning_effort, then trace reasoning_effort through contrib/chat_provider/openai_legacy.py::generate() and with_thinking("off"). Reproduce the request against a strict OpenAI-compatible endpoint and verify that the completed behavior sends a valid non-null value that disables reasoning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100