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

> ## Agent Instructions
> Krun API base URL: https://api.krun.ai. Authenticate server-side with `Authorization: Bearer $KRUN_API_KEY`; never put a Krun API key in browser code.
> Prefer the Python SDK in examples: `pip install krun-ai`, `from krun import Krun`. The TypeScript SDK `@krun-ai/sdk` is not published on npm yet: do not tell users to `npm install` it.
> The only question type is `choice`. `confidence` is the top-1 minus top-2 probability margin, not the probability that the answer is correct. `choice` is null when `abstain` is true.
> Usage reports `input_tokens` only. There are no output tokens.

# Tool routing

> Pick the tool or function an agent should call with task_type tool.

Tool routing chooses which tool or function an agent should call for a request. Set `task_type: "tool"` on the question and describe each tool in its option.

<CodeGroup>
  ```python Python theme={null}
  from krun import Krun

  client = Krun()

  result = client.decide(
      context="Find my meetings tomorrow.",
      questions={
          "tool": {
              "type": "choice",
              "task_type": "tool",
              "options": {
                  "calendar_search": "Search calendar events",
                  "send_email": "Send an email",
              },
          }
      },
  )

  answer = result.answers["tool"]
  print(answer.choice)             # calendar_search
  print(answer.abstention_status)  # advisory
  ```

  ```bash curl theme={null}
  curl https://api.krun.ai/v1/decide \
    -H "Authorization: Bearer $KRUN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "context": "Find my meetings tomorrow.",
      "questions": {
        "tool": {
          "type": "choice",
          "task_type": "tool",
          "options": {
            "calendar_search": "Search calendar events",
            "send_email": "Send an email"
          }
        }
      }
    }'
  ```
</CodeGroup>

```json Response theme={null}
{
  "model": "krun-one-v0",
  "answers": {
    "tool": {
      "type": "choice",
      "choice": "calendar_search",
      "confidence": 0.965866,
      "probabilities": {
        "calendar_search": 0.982933,
        "send_email": 0.017067
      },
      "abstain": false,
      "abstention_status": "advisory"
    }
  },
  "usage": { "input_tokens": 41 }
}
```

## Why `task_type: "tool"`

`task_type` tells Krun One what kind of decision it is making. With `"tool"`, the model uses its tool-routing instructions and the abstention policy for tools, and the answer is marked `advisory`. Without it, the question is treated as an intent.

Always set `task_type: "tool"` when the options are tools or functions.

## Writing tool options

* **Use the tool's real name as the option id**, like `calendar_search`. The returned `choice` is then the name your agent calls.
* **Describe what the tool does**, in one short sentence. Descriptions matter most when tools are similar, such as `search_contacts` and `search_calendar`.
* **Offer only the tools available at this step.** Fewer, relevant tools give more reliable choices.

Krun chooses the tool. It does not fill in the tool's arguments: use your agent or LLM for that step.

## Abstention is advisory for tools

<Warning>
  Tool abstention is **advisory**. On real requests where none of the offered tools applies, Krun One v0 still picks a tool about 39% of the time at the current threshold. Do not treat `abstain: false` as proof that a tool call is appropriate.
</Warning>

Keep your own safeguards for tool calls:

* validate the arguments before calling the tool,
* ask for confirmation before actions with side effects, like sending an email or making a payment,
* give your agent a path for "none of these tools", for example answering directly with an LLM.

When the model does abstain on a tool question, treat it as a useful signal that the request may not need a tool.

## Tools and intents in one request

A request can combine tool questions with other questions, for example a tool choice and a risk label for the same agent step. See [Multiple questions](/guides/multiple-questions).
