Skip to main content
An Agent is a persistent, versioned configuration object in Kimi Hosted Agents that defines how it runs: model selection, the system prompt, and available tools. A Session references an agent via agent_id to run tasks and pins the agent version active when the session is created.
Every update to an agent’s configuration produces a new immutable version, while older versions remain intact. Existing sessions continue using the version pinned at creation time and are unaffected by subsequent updates—ensuring consistent behavior even when long-running tasks pause and resume.

Agent fields

Tool declarations

The tools array declares which tools the agent can use. Each entry is distinguished by its type field: If no agent_toolset is declared on creation, agent_toolset_20261101 is prepended to tools by default (counting toward the 128-item limit). Once you explicitly declare an agent_toolset, only the declared toolset is loaded; each tools list allows at most one sandbox toolset, and mixing agent_toolset_20260901 with agent_toolset_20261101 returns 400 invalid_parameter_error. To disable sandbox tools, explicitly declare an agent_toolset with default_config.enabled set to false for the entire toolset. For detailed tool configuration options, see Tools.

MCP servers

mcp_servers stores connection metadata: type (currently only "url" is supported), name, url, and optional headers. headers specifies custom non-sensitive HTTP request headers (such as User-Agent or tenant routing headers), up to 16 entries; they are accepted in requests and omitted from responses. On update, the entire mcp_servers array is replaced—any server omitted from the request is removed. headers follows a different rule: if headers is omitted or empty and the server’s name, type, and url are unchanged, existing headers are preserved; if headers is non-empty, it replaces all headers for that server, and setting a key to an empty string deletes that key. Access credentials are not stored in the agent configuration—instead, they are injected via a Vault when creating a session. See MCP and Vaults.

Skill references

Each entry in skills contains skill_id and version. When creating or updating an agent, omitting version pins it to the latest version available at write time; specifying an exact version pins that version; explicitly passing "latest" preserves the literal "latest" value and re-resolves it whenever the agent is read or woken up. See Skills for details.

Official agents vs. custom agents

Agents fall into two categories:
Official agents are read-only: you can inspect their full configuration and reference them directly when creating sessions, but update and archive requests are rejected. To customize one, create your own custom agent based on the official agent’s configuration.

API endpoints

When listing agents, you can pass exclude_multiagent=true to return only agents without multiagent configured—useful when building a delegation list and filtering out agents that already delegate to others. In addition to the console and REST API, you can create, update, and archive agents with the kha CLI. The examples below show both cURL and kha CLI commands; cURL examples read your API key from the KIMI_API_KEY environment variable.

Create an agent

Creating a minimal working agent requires only name and model, though you will typically include a system prompt as well. A successful request returns the full agent object, including its id and initial version. Save the id for creating sessions later.
The --file flag in kha accepts both JSON and YAML, and - reads from standard input. Request bodies with nested structures must be passed as a single payload via --file and cannot be combined with individual field flags. See Request body input for details.

Update an agent

Updates follow an immutable versioning model: PATCH does not mutate the configuration in place, but instead creates a brand-new immutable version based on the current configuration while preserving earlier versions. On the agent details page in the console, you can edit the current version from the Configuration tab; saving also creates a new immutable version. Keep two rules in mind when updating via the API:
  1. Optional version concurrency control: You can include the current version returned when reading the agent in the request body. If the agent was modified in the meantime, the server responds with 409; re-fetch the latest version and retry. Omitting version skips the concurrency check.
  2. Only included fields are updated: Omitting a field leaves it unchanged; explicitly passing null returns 400 (invalid_parameter_error). Array fields (skills, plugins) and metadata are replaced in full—pass an empty array or empty object to clear them. tools follows the same rule, except that omitting agent_toolset (including passing []) keeps the current version’s agent_toolset declarations, or prepends agent_toolset_20261101 if none exists; if you update an older version that has no agent_toolset and omit tools, the request returns 400 failed_precondition_error. mcp_servers replaces the array in full, except for headers, which preserves or replaces entries according to the rules under “MCP servers” above.
The example below updates only the system prompt while leaving all other settings unchanged:
Updating an agent does not affect existing sessions—each session pins the agent version at creation time and continues using that version even after interruption and recovery. Only newly created sessions pick up the updated version.

View version history

Every update creates a new immutable version. You can inspect the full configuration of any historical version through the version history endpoint. Results are paginated; use next_page_token in the response to fetch the next page (the field is omitted when there are no more results).
On the agent details page in the console, you can also browse historical versions using the Agent Version selector on the Configuration tab. Selecting a historical version populates the form with its full configuration and displays a notice stating that historical versions are read-only snapshots and cannot be saved. For unarchived custom agents, switch back to Current Version to continue editing and saving—saving creates a new immutable version without overwriting historical versions.

View associated resources and runtime metrics

The agent details page in the console also provides the following tabs:
  • Sessions: Lists sessions and their pinned versions, with filtering by version, source, and status. After an agent is updated, existing sessions continue displaying the version pinned at creation time; newly created sessions without an explicit version use the current version.
  • Deployments: Shows associated triggers along with their version, next run, last run, and creation time.
  • Observability: Shows total sessions, session success rate, tool calls, and token usage, as well as recent sessions and associated triggers.

Archive an agent

When an agent is no longer needed, you can archive it by selecting Archive from the action menu in the console’s agent list or by calling the archive endpoint. Once archived:
  • The agent becomes read-only, and update requests are rejected.
  • It is hidden by default from the agent list and the agent selector when creating a session, and can no longer be used to create new sessions.
  • The agent and its historical versions remain directly readable.
  • Existing sessions are unaffected and can continue running and resuming.
Archiving succeeds with 204 and an empty response body—do not attempt to parse response JSON.
Archiving is irreversible. Confirm that you no longer need to create new sessions with this agent before proceeding.

Next steps

Start a task with your agent

Launch a task session using the agent you created.

Configure built-in and custom tools

Learn how to configure the built-in toolset and custom tools.

Attach skills

Mount versioned skill packages onto your agent.

Connect MCP servers

Connect remote MCP servers and inject access credentials.

Manage access credentials

Store and manage credentials for MCP and external services.