Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

openai_legacy provider drops reasoning content, causing APIEmptyResponseError #1155

Description

@rongou

Description

When using kimi-cli with an OpenAI-compatible server (e.g. sglang or vllm) that separates reasoning/thinking content into a dedicated response field, the openai_legacy provider drops all reasoning content because reasoning_key is never passed to the OpenAILegacy constructor.

The underlying kosong library's OpenAILegacy class already supports a reasoning_key constructor parameter that tells the stream handler which field to read thinking content from. But create_llm() in llm.py never passes it:

case "openai_legacy":
    chat_provider = OpenAILegacy(
        model=model.model,
        base_url=provider.base_url,
        api_key=resolved_api_key,
    )

Impact

When the model produces a response consisting solely of reasoning/thinking (no text content, no tool calls), the stream yields zero parts and kosong/_generate.py raises APIEmptyResponseError("The API returned an empty response."). The agent crashes even though the server returned a valid response.

Proposed fix

  1. Add an optional reasoning_key: str | None = None field to LLMProvider in config.py.
  2. Pass reasoning_key=provider.reasoning_key when constructing OpenAILegacy in create_llm().

This allows users to configure e.g.:

[providers.vllm]
type = "openai_legacy"
base_url = "http://localhost:8000/v1"
api_key = "dummy"
reasoning_key = "reasoning_content"

PR: #1154

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions