Skip to content

Kimi adapter: live gaps (empty-config LLMNotSet, structured output) — blocked on MCP co-install (#29) #36

Description

@pofallon

Two real gaps in the Kimi adapter surfaced while verifying it live (in a separate .venv-kimi, since it can't co-install with claude-agent-sdk — see #29). Both are deferred until the MCP conflict in #29 resolves, because Kimi can't be exercised in CI or alongside the other providers until then.

Gap 1 — LLMNotSet against a fresh setup (blocks all live use)

KimiSession._ensure_sdk_session passes config=None to Session.create and relies on the SDK's env-var augmentation (KIMI_API_KEY / KIMI_BASE_URL / KIMI_MODEL_NAME). But that augmentation only mutates a pre-existing "kimi"-type provider; a default ~/.kimi/config.toml is empty (providers = {}, models = {}), so there's nothing to augment → kosong … LLMNotSet: LLM not set. The in-code comment at kimi.py:1332-1338 already flags this as deferred ("a future iteration may route through Config properly").

Proven fix (spiked live — it reaches the Moonshot API): build a kimi_cli.config.Config from the adapter's resolved api_key / base_url / model and pass it as config= to Session.create:

from kimi_cli.config import Config, LLMProvider, LLMModel
from pydantic import SecretStr
cfg = Config(
    default_model=model_id,
    models={model_id: LLMModel(provider="moonshot", model=model_id,
                               max_context_size=256_000, capabilities={"thinking"})},
    providers={"moonshot": LLMProvider(type="kimi", base_url=base_url, api_key=SecretStr(api_key))},
)
sess = await Session.create(work_dir=…, config=cfg, model=model_id, yolo=…, thinking=…)

With this, LLMNotSet disappears and the request reaches Moonshot (verified: it then returned a 429 account-balance error — i.e. auth + config + request path all work).

Gap 2 — structured output declared but not wired

KimiSession._gate_and_coerce_prompt (kimi.py:1304-1314) rejects schema= with NotImplementedError, yet the runtime declares STRUCTURED_OUTPUT_JSON_SCHEMA = True (a conformance requirement). Intended approach (per the module docstring): a forced submit_result tool mirroring CopilotRuntime. Constraint discovered: Kimi's Session.create() exposes only agent_file + mcp_configs (no in-process tools=, no tool_choice), so it must run a FastMCP submit_result server + force the call via system prompt + capture the args off the wire stream — and that forcing behavior needs a live spike to validate (no tool_choice).

Status

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