> ## Documentation Index
> Fetch the complete documentation index at: https://platform.kimi.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Permissions

> Configure tool permissions for hosted agents to allow execution automatically or require client confirmation, and inspect per-call evaluation results.

Two fields control how a hosted agent uses tools: `enabled` determines whether a tool is exposed to the model, and `permission_policy` determines how the platform evaluates a tool call from the model. Use them to disable tools that modify external state—such as writing files, running commands, or calling external services—or to require confirmation before those tools execute.

## Configuration fields

| Field | What it controls | Values and default |
| - | - | - |
| `enabled` | Whether the tool is exposed to the model | Enabled by default; set to `false` to disable the tool so the model cannot see or call it |
| `permission_policy` | How tool calls from the model are evaluated | `always_allow`: execute immediately; `always_ask`: pause and wait for client confirmation. Defaults to `always_allow` |

Both fields apply to built-in toolsets (`agent_toolset`) and MCP toolsets (`mcp_toolset`), and both can be configured at two levels:

* **Toolset level**: Set inside `default_config` on the toolset declaration as the default for all tools in that toolset.
* **Per-tool level**: Set the same field for an individual tool inside `configs` to override the toolset-level default.

When neither level is configured, tools are enabled by default and evaluated under `always_allow`—the platform executes the tool immediately when the model calls it. For every tool call, the evaluated decision is delivered to the client in the `evaluated_permission` field of the `agent.tool_use` event.

### Handle `always_ask` confirmations

When the model calls a tool configured with `always_ask`, the platform emits an `agent.tool_use` event, pauses execution, and waits for the client to reply with a `user.tool_confirmation` event via `POST /v1/sessions/{session_id}/events`. Once the confirmation result arrives, the platform either executes or skips the tool call. For details on subscribing to and resuming event streams, see [Event Stream](https://platform.kimi.ai/docs/hosted-agents/event-stream.md).

Pass the top-level `id` from the originating `agent.tool_use` event as `event_id`. To approve execution, set `result` to `allow`:

```bash theme={null}
curl -X POST "https://api.moonshot.ai/v1/sessions/$SESSION_ID/events" \
  -H "Authorization: Bearer $KIMI_API_KEY" \
  -H "kimi-api-version: 2026-09-01-beta" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "type": "user.tool_confirmation",
        "data": {
          "event_id": "sevt_01h455vb4pex5vsknk084sn02s",
          "result": "allow"
        }
      }
    ]
  }'
```

To deny execution, set `result` to `deny` and optionally include `deny_message` to explain the reason; when allowing execution, `deny_message` must be empty. The request must contain only tool confirmation events; the endpoint returns `202` when accepted.

> [!TIP]
>
> Recommended practice: leave read-only tools at the default `always_allow` policy; set tools that can modify external state to `always_ask`; and set `enabled: false` at the toolset or per-tool level for any tool the agent should never use.

## Configure tool permissions

Include both fields in your tool declarations when you [create an agent](https://platform.kimi.ai/docs/hosted-agents/agents.md). You can also modify these settings on an existing agent: pass the `tools` field when you [update an agent](https://platform.kimi.ai/docs/hosted-agents/agents.md#update-an-agent), which creates a new agent version without recreating the agent. `tools` replaces custom and MCP tool declarations in full; if the array omits `agent_toolset`, the current version's `agent_toolset` declaration is kept (or `agent_toolset_20261101` is prepended if none exists). The example below sets automatic approval as the default for the built-in toolset while disabling `write`:

```bash cURL theme={null}
curl -X POST https://api.moonshot.ai/v1/agents \
  -H "Authorization: Bearer $KIMI_API_KEY" \
  -H "kimi-api-version: 2026-09-01-beta" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Coding Assistant",
    "model": {"id": "kimi-k3.1-pro"},
    "system": "You are a rigorous coding assistant.",
    "tools": [
      {
        "type": "agent_toolset",
        "name": "agent_toolset_20261101",
        "default_config": {
          "permission_policy": "always_allow"
        },
        "configs": [
          {
            "name": "write",
            "enabled": false
          }
        ]
      }
    ]
  }'
```

```bash CLI theme={null}
kha agents create --file - <<'JSON'
{
  "name": "Coding Assistant",
  "model": {"id": "kimi-k3.1-pro"},
  "system": "You are a rigorous coding assistant.",
  "tools": [
    {
      "type": "agent_toolset",
      "name": "agent_toolset_20261101",
      "default_config": {
        "permission_policy": "always_allow"
      },
      "configs": [
        {
          "name": "write",
          "enabled": false
        }
      ]
    }
  ]
}
JSON
```

`configs[].name` must use a tool name from the selected toolset version: for example, the file-writing tool is named `write` in `agent_toolset_20261101`, and `write_file` in `agent_toolset_20260901` (legacy name `default_toolset_20260901`).

### MCP toolsets

MCP toolsets configure `enabled` and `permission_policy` in `default_config` and `configs` in the same way. `mcp_server_name` must reference a server declared in the same agent's `mcp_servers`, and `configs[].name` uses the actual tool name exposed by that MCP server.

```json theme={null}
{
  "type": "mcp_toolset",
  "mcp_server_name": "todo",
  "default_config": {
    "permission_policy": "always_allow"
  },
  "configs": [
    {
      "name": "delete_task",
      "enabled": false
    }
  ]
}
```

For details on declaring MCP servers, where tool names come from, and how `configs` behaves when a server's tool list changes, see [Configure MCP Servers](https://platform.kimi.ai/docs/hosted-agents/mcp.md).

## Next steps

> [card] [Configure tool declarations](https://platform.kimi.ai/docs/hosted-agents/tools.md)
>
> Learn how to declare built-in toolsets and MCP tools.

> [card] [Handle tool confirmation events](https://platform.kimi.ai/docs/hosted-agents/event-stream.md)
>
> Receive tool call and session status events in real time.
