Skip to content

Add a Kimi Code CLI Harness #1888

Closed

Description

@JacobStephens2

This was generated by AI during a grill-with-docs session.

Idea

Add a Kimi CLI Harness, so Kimi K3.1 Pro served by Fireworks can be a seat on the Grader panel of Spec #1872, and later an Arm or a Ticket run's Harness. Decided in docs/grill-with-docs/1484-implement-suite.md (Q6.4 (b), Q7.1, Q7.2), against the recommendation to use opencode. Research: docs/research/eval-grader-panel.md §1.

What's known

  • Kimi CLI runs headless (--print, stream-json), but its docs say nothing about token usage in its output.
  • An adapter is about 1,000 lines: setup, sandbox provider hosts, sign-in or API key, usage, session traces and interpretation.

Decided

  • Check first. The work starts by checking Kimi CLI's real headless output. If it reports usage, use that. If not, the Harness estimates usage from the transcript's characters, priced from the frozen price table and labelled estimated in every report, and the panel's spending limit counts the estimate (Q7.1).
  • It's its own issue, built and tested like the other Harnesses. Spec: blind pairwise grading of process Trials by a Grader panel and people #1872's panel waits on it only for Kimi seats (Q7.2).

For triage

Whether this is one Ticket or needs a Spec, and whether the Fireworks host it needs comes from #1883 or from this issue.

Activity

  1. added
    enhancement
    needs-triage
    on Nov 9, 2026
  2. JacobStephens2 commented on Nov 9, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Agent Brief

    Category: enhancement
    Summary: Add a kimi Harness running Kimi Code CLI headless, so a Model such as Kimi K3.1 Pro on Fireworks can run a Command's sessions and later sit on #1872's Grader panel.

    Triage findings (2026-11-09):

    • Use Kimi Code CLI. The Python Kimi CLI (MoonshotAI/kimi-cli, 1.52.0) is archived and its README points to Kimi Code CLI (MoonshotAI/kimi-code, npm @moonshot-ai/kimi-code, 2.5.2, MIT). Kimi Code CLI installs the same kimi binary. Build against Kimi Code CLI.
    • Usage is reported, so the plan to estimate it is dropped. kimi -p … --output-format stream-json writes Assistant and Tool messages but no usage. The session's own record does include it: each step.end event in <KIMI_CODE_HOME>/sessions/…/agents/main/wire.jsonl carries usage (inputOther, output, inputCacheRead, inputCacheCreation). KIMI_CODE_HOME defaults to ~/.kimi-code, and Kimi's own vis tool sums usage from those events. That replaces the grill's Q7.1 plan to estimate usage from characters.
    • Fireworks works without special support. Kimi Code CLI takes an OpenAI-compatible provider with a base_url (kimi provider import … --base-url, config.toml providers, or KIMI_MODEL_* environment variables).
    • Past Harnesses were one Ticket each. agy, grok, muse and opencode (Add the agy Harness (Antigravity CLI) #436–Add the opencode Harness (OpenCode) #439) were each a single Ticket, so this is one Ticket too.

    Current behavior:
    The Harnesses are claude, codex, agy, grok, muse and opencode. Kimi Models run only through opencode, and the sandbox proxy's provider hosts include no Fireworks host.

    Desired behavior:
    harness kimi runs a Command's sessions on Kimi Code CLI wherever the other Harnesses can be chosen, including [harness.kimi] and Setup, like the grok Harness (#437).

    • Each session runs kimi -p <prompt> --output-format stream-json with stdin null. Non-interactive mode already approves automatically, and --yolo can't be combined with -p. The session gets its own KIMI_CODE_HOME, or a known one, so that its wire.jsonl can be found.
    • Resume uses kimi --session <id> (alias -r). The Harness gets the session id from Kimi's output or its session folder.
    • The stream parser gives progress lines, the final message and errors. Usage is the total of step.end usage events in the session's wire.jsonl, by Model, mapped onto thirdshift's usage fields with cache reads and writes kept apart.
    • The Model is checked before any work runs, and a bad Model fails with the valid ones named. A Fireworks Model is set up as an OpenAI-compatible provider whose key comes from an environment variable, never written into the repository.
    • Factory skills load the way the other Harnesses load them. Kimi Code reads AGENTS.md. The Harness's docs say which instruction files and skill folders it reads.
    • The sandbox proxy lets a kimi session reach its provider's hosts and no others. Fireworks' API host (api.fireworks.ai) is added as a provider host in this Ticket. Allow Fireworks and Baseten through opencode, with a key per provider #1883, a Ticket inside Spec Spec: blind pairwise grading of process Trials by a Grader panel and people #1872, reaches main only when that Spec merges, so this Ticket must not wait for it. Whichever of the two lands second finds the host already there. The Kimi Code sign-in hosts are allowed when the session uses the managed Kimi provider.
    • Session traces and interpretation work like the other Harnesses', from the stream and wire.jsonl.

    Key interfaces:

    • Harness enum and its adapter: a new Kimi variant with name kimi.
    • Provider hosts for the sandbox proxy: the kimi Harness, plus a Fireworks host list.
    • [harness.kimi] config: Model, provider, and the name of the API-key environment variable.

    Acceptance criteria:

    • harness kimi runs a Command's session, using the fake-Harness test pattern the other Harnesses use. The session runs kimi -p with --output-format stream-json, stdin null, and a set KIMI_CODE_HOME.
    • The session's usage equals the total of the step.end usage events in its wire.jsonl, across several steps, with input, output, cache-read and cache-write tokens kept apart. A session with no step.end usage reports usage as missing, not zero.
    • A Resume runs kimi --session <id> with the first session's id.
    • A bad Model fails before any work runs and names the valid ones.
    • A sandboxed kimi session on a Fireworks Model can reach api.fireworks.ai and nothing else through the proxy. The existing check that each Harness gets only its provider's hosts covers kimi.
    • Interrupting a Run stops the commands Kimi started, and the tree-stop scenario test passes on kimi.
    • Setup offers kimi when kimi is installed.
    • The guide (and the generated manual) and the site pages that list Harnesses include kimi.
    • Before the Harness is marked done, a real kimi run's wire.jsonl is checked to have the step.end usage shape above. If the shape has changed, the parser follows the real output and a test fixture records it.

    Out of scope:

  3. added
    ready-for-agent
    and removed
    needs-triage
    on Nov 9, 2026
  4. changed the title [-]Add a Kimi CLI Harness[/-] [+]Add a Kimi Code CLI Harness[/+] on Nov 9, 2026
  5. added a commit that references this issue on Nov 9, 2026
  6. added
    in-progress
    and removed
    ready-for-agent
    on Nov 9, 2026
  7. removed
    in-progress
    on Nov 10, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions