Skip to content

v0.6.0

Latest

Choose a tag to compare

@neo-f neo-f released this 03 Dec 05:47
a91931d

KHA v0.6.0

Go SDK and CLI for Kimi Hosted Agents.

What changed

This release adds project Webhooks with signature verification, the agent_toolset_20261101 built-in toolset, Skill delivery and protocol negotiation for self-hosted workers, and X-Language localization for Plugin and Skill APIs.
Three breaking changes require attention when upgrading: new Agents default to agent_toolset_20261101; ToolResultBlock.StructuredContent no longer duplicates plain-text tool output — fall back to Content when it is empty; and per-operation 429 header types are consolidated into TooManyRequestsErrorResponseHeaders.

agent_toolset_20261101 and explicit toolset declarations (breaking change)

Built-in sandbox toolsets use agent_toolset_<date> names: agent_toolset_20260901 (AgentToolsetNameAgentToolset20260901) and agent_toolset_20261101 (AgentToolsetNameAgentToolset20261101: read, write, edit, bash, glob, grep, web_search, web_fetch, save_artifact).
AgentToolsetNameDefaultToolset20260901 ("default_toolset_20260901") remains accepted as a deprecated alias of agent_toolset_20260901.

  • Default for new Agents: POST /v1/agents prepends agent_toolset_20261101 when no agent_toolset is declared (counting toward the 128-item limit). Existing Agent versions keep their saved toolset. To keep legacy 0901 tools on newly created Agents, explicitly declare {"type": "agent_toolset", "name": "agent_toolset_20260901"} in tools.
  • Updates and overrides keep the current toolset: Replacing Agent tools or setting Session agent_overrides.tools without an agent_toolset preserves the current (or bound Agent's) agent_toolset, or prepends agent_toolset_20261101 if none exists (tools: [] on Session update still clears the override). Each tools list allows at most one sandbox toolset (400 invalid_parameter_error). Updating an older Agent version without an agent_toolset while omitting tools returns 400 failed_precondition_error — include tools to pin one. To disable all built-in tools, keep the agent_toolset entry with default_config: {"enabled": false}.
  • Self-hosted support: Self-hosted Environments and kha worker now support agent_toolset_20261101 alongside agent_toolset_20260901 (and its deprecated alias). Local workers execute read, write, edit, bash (resolving KHA_BASH_PATH, bash on PATH excluding workspace/WSL stubs, or Git Bash/MSYS2 on Windows; sh -c fallback on Unix), and glob/grep (preferring non-workspace rg on PATH with a bounded pure-Go fallback; multiline requires rg), while web_search and web_fetch run on the platform and save_artifact remains disabled. Upgrade workers before selecting agent_toolset_20261101 on self-hosted Sessions; unsupported future toolsets with enabled tools are rejected with 400.

structured_content no longer duplicates content (breaking change)

ToolResultBlock.StructuredContent now carries only tool-provided user-facing views (such as artifact cards or media/search summaries) and is [] when none exists — including text-file read/read_file, write, write_file, edit, bash, shell, glob, grep, self-hosted worker tools, MCP tools, and failed calls without display blocks.
Model-facing output (including any result_hint text block) and raw error details live in ToolResultBlock.Content; previously persisted events retain their existing StructuredContent, and IsError still indicates failure.

Clients that previously read only StructuredContent must fall back to Content when StructuredContent is empty.

Shared 429 response headers and protocol runtime fixes (breaking change)

Resource methods, request and response models, New/NewClient, and pagination, waiter, and event-stream APIs keep their existing signatures.

  • Rate-limit header types consolidated: Per-operation <Operation>TooManyRequestsHeaders structs and Parse<Operation>TooManyRequestsHeaders functions (such as ListAgentsTooManyRequestsHeaders) are replaced by shared TooManyRequestsErrorResponseHeaders and ParseTooManyRequestsErrorResponseHeaders (RetryAfter *int32). Update callers referencing those types by name; reading Retry-After from HTTPResult.Header or HTTP error metadata is unchanged.
  • JSON, HTTP, and SSE fixes: Structs reset before decode, malformed JSON (such as nan) reports a syntax error, multipleOf and large int64 bounds use exact math/big arithmetic, const/uniqueItems compare canonical JSON, non-discriminated oneOf requires one exact match, and map validation error order is unspecified. Retries and per-request BaseURL parse failures close bodies cleanly, multipart state no longer leaks across retries, SSE handles CR-only endings and cross-buffer events, and application/json-seq rejects truncated records.

Project Webhooks and signature verification

  • Manage project Webhooks and rotate signing secrets via client.Webhooks and the Webhooks.All iterator (ordered newest first). New endpoints start disabled; signing secrets are returned once on create/rotate. Enabled responses omit disabled_reason; disabled responses return manual or delivery_failures as *WebhookDisabledReason.
  • Generated WebhookEvent.Data accessors expose typed business payloads; WebhookSender delivers events directly, and WithRequestHook can sign final request body bytes.
  • Disabling (manual or automatic) or deleting an endpoint stops only future event capture; already captured deliveries and retries continue with their original URL and signing secret.
  • VerifyProjectWebhookSignature verifies HMAC-SHA256 over unmodified request bytes with a full whsec_<base64> secret and a ±5-minute timestamp window (see README.md for verify-before-parse, event-ID deduplication, and key rotation). Existing Trigger notifications continue using VerifyWebhookSignature with the raw Vault secret.

Self-hosted worker protocol, Skills, and reliability

  • Worker protocol version: kha worker poll and environments work poll send worker_version=1. Sessions declaring only agent_toolset_20260901 (or its alias) or no sandbox toolset require version 0, while agent_toolset_20261101 requires version 1 (updating agent_overrides re-derives pending items). Older workers (version 0) keep claiming 0901 sessions without picking up incompatible work during rollout.
  • Skill delivery and ${KHA_WORKDIR}: GetSession adds Include (resolved_skills, populating Session.ResolvedSkills as SkillVersion entries), and Skills.GetVersionContent adds Format (markdown or archive, returning HTTPResult[io.ReadCloser]). Workers clear KHA_WORKDIR/skills and stale .kha-staging-* directories before installing Skill archives — keep custom files elsewhere in the workdir. Self-hosted Sessions advertise ${KHA_WORKDIR}/skills/<name>/SKILL.md (cloud paths remain /mnt/agents/skills/<name>/SKILL.md); file tools expand ${KHA_WORKDIR} and resolve relative paths against the workdir, and shell/bash commands run in that workdir with KHA_WORKDIR set.
  • Lease and idle bounds: Queue and event requests enforce per-request deadlines (30s for Heartbeat, ListEvents, and Ack; block_ms + 15s for Poll) as retryable failures. Leases are abandoned without Stop after a full TTL without a successful heartbeat, and observing lease loss immediately cancels in-flight tools. With positive --max-idle (or --session-max-idle), idle settlement triggers after max(3*maxIdle, 3m) with no in-flight tools (409 resets the quiet window while the Session stays active).
  • read_file output format: Self-hosted read_file now outputs unpadded <line>\t<content> without the cat -n header or trailing blank line, matching the managed platform (older workers remain compatible during compaction).

Localized Plugin and Skill text via X-Language

Plugin (List, Get, Create, CreateVersion) and Skill (List, Get, Create) request structs add optional XLanguage to send the X-Language header (BCP 47, such as en-US or zh-CN). Omitting it or sending an unsupported locale defaults to zh-CN with base-text fallback; existing callers need no changes.

History pagination and live stream cursors

Generated event-list documentation now distinguishes history next_page_token from live stream_cursor: use the final page's cursor for ascending pagination, keep the newest first page's cursor for descending pagination, and reconnect live streams using the latest SSE event ID while deduplicating by event id.

CLI examples and embedded skill

CLI help examples and the embedded skill (kha install-skill) now use agent_toolset_20261101 and kimi-k3.1-pro, document agent_toolset preservation on updates/overrides, and instruct agents to fall back to data.tool_result.content when data.tool_result.structured_content is empty.
Run kha install-skill (or kha install-skill -g for user-level installs) after upgrading to refresh an installed copy (kha upgrade refreshes standard copies automatically).

Installation

Go SDK

go get github.com/MoonshotAI/kha@v0.6.0

CLI

macOS / Linux:

curl -fsSL https://ha-static.moonshot.cn/kha/install.sh | KHA_VERSION=0.6.0 sh

Windows PowerShell:

$installer = Join-Path ([IO.Path]::GetTempPath()) 'kha-install.ps1'
Invoke-WebRequest https://ha-static.moonshot.cn/kha/install.ps1 -UseBasicParsing -OutFile $installer
& $installer -Version 0.6.0

You can also download a platform archive and checksums.txt from this release.

Links