Repository navigation
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/agentsprependsagent_toolset_20261101when noagent_toolsetis 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"}intools. - Updates and overrides keep the current toolset: Replacing Agent
toolsor setting Sessionagent_overrides.toolswithout anagent_toolsetpreserves the current (or bound Agent's)agent_toolset, or prependsagent_toolset_20261101if none exists (tools: []on Session update still clears the override). Eachtoolslist allows at most one sandbox toolset (400invalid_parameter_error). Updating an older Agent version without anagent_toolsetwhile omittingtoolsreturns 400failed_precondition_error— includetoolsto pin one. To disable all built-in tools, keep theagent_toolsetentry withdefault_config: {"enabled": false}. - Self-hosted support: Self-hosted Environments and
kha workernow supportagent_toolset_20261101alongsideagent_toolset_20260901(and its deprecated alias). Local workers executeread,write,edit,bash(resolvingKHA_BASH_PATH,bashonPATHexcluding workspace/WSL stubs, or Git Bash/MSYS2 on Windows;sh -cfallback on Unix), andglob/grep(preferring non-workspacergonPATHwith a bounded pure-Go fallback;multilinerequiresrg), whileweb_searchandweb_fetchrun on the platform andsave_artifactremains disabled. Upgrade workers before selectingagent_toolset_20261101on 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>TooManyRequestsHeadersstructs andParse<Operation>TooManyRequestsHeadersfunctions (such asListAgentsTooManyRequestsHeaders) are replaced by sharedTooManyRequestsErrorResponseHeadersandParseTooManyRequestsErrorResponseHeaders(RetryAfter *int32). Update callers referencing those types by name; readingRetry-AfterfromHTTPResult.Headeror HTTP error metadata is unchanged. - JSON, HTTP, and SSE fixes: Structs reset before decode, malformed JSON (such as
nan) reports a syntax error,multipleOfand largeint64bounds use exactmath/bigarithmetic,const/uniqueItemscompare canonical JSON, non-discriminatedoneOfrequires 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, andapplication/json-seqrejects truncated records.
Project Webhooks and signature verification
- Manage project Webhooks and rotate signing secrets via
client.Webhooksand theWebhooks.Alliterator (ordered newest first). New endpoints start disabled; signing secrets are returned once on create/rotate. Enabled responses omitdisabled_reason; disabled responses returnmanualordelivery_failuresas*WebhookDisabledReason. - Generated
WebhookEvent.Dataaccessors expose typed business payloads;WebhookSenderdelivers events directly, andWithRequestHookcan 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.
VerifyProjectWebhookSignatureverifies HMAC-SHA256 over unmodified request bytes with a fullwhsec_<base64>secret and a ±5-minute timestamp window (seeREADME.mdfor verify-before-parse, event-ID deduplication, and key rotation). Existing Trigger notifications continue usingVerifyWebhookSignaturewith the raw Vault secret.
Self-hosted worker protocol, Skills, and reliability
- Worker protocol version:
kha worker pollandenvironments work pollsendworker_version=1. Sessions declaring onlyagent_toolset_20260901(or its alias) or no sandbox toolset require version 0, whileagent_toolset_20261101requires version 1 (updatingagent_overridesre-derives pending items). Older workers (version 0) keep claiming 0901 sessions without picking up incompatible work during rollout. - Skill delivery and
${KHA_WORKDIR}:GetSessionaddsInclude(resolved_skills, populatingSession.ResolvedSkillsasSkillVersionentries), andSkills.GetVersionContentaddsFormat(markdownorarchive, returningHTTPResult[io.ReadCloser]). Workers clearKHA_WORKDIR/skillsand 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 withKHA_WORKDIRset. - Lease and idle bounds: Queue and event requests enforce per-request deadlines (
30sforHeartbeat,ListEvents, andAck;block_ms + 15sforPoll) as retryable failures. Leases are abandoned withoutStopafter 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 aftermax(3*maxIdle, 3m)with no in-flight tools (409resets the quiet window while the Session stays active). read_fileoutput format: Self-hostedread_filenow outputs unpadded<line>\t<content>without thecat -nheader 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.0CLI
macOS / Linux:
curl -fsSL https://ha-static.moonshot.cn/kha/install.sh | KHA_VERSION=0.6.0 shWindows 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.0You can also download a platform archive and checksums.txt from this release.