Quancisuancis

Build

Tool calling

Let Kael call your functions, and how the review pass treats tool calls.

The loop

Tool calling works the way it does in the OpenAI and Anthropic APIs. You describe your functions in tools. When Kael wants one run, it replies with a tool call instead of text. You run the function and send the result back, and Kael continues.

tools = [{
    "type": "function",
    "function": {
        "name": "get_order_status",
        "description": "Look up an order by its id.",
        "parameters": {
            "type": "object",
            "properties": {"order_id": {"type": "string"}},
            "required": ["order_id"],
        },
    },
}]

messages = [{"role": "user", "content": "Where is order A-1042?"}]
first = client.chat.completions.create(model="kael-beta", messages=messages, tools=tools)

call = first.choices[0].message.tool_calls[0]  # finish_reason is "tool_calls"
messages.append(first.choices[0].message)
messages.append({
    "role": "tool",
    "tool_call_id": call.id,
    "content": '{"status": "shipped", "arrives": "Friday"}',  # your function's result
})

final = client.chat.completions.create(model="kael-beta", messages=messages, tools=tools)
print(final.choices[0].message.content)

How tool calls behave

  • The review pass sees tool calls. If Kael's draft chooses a tool, the review reads that choice and can change which tool is called or its arguments. This is one reason tool requests take longer.
  • Kael decides when to call a tool. tool_choice is accepted but not enforced.
  • Only your own function tools exist. Kael has no built-in web search, code execution, or file search through the API.
  • Streaming: on Chat Completions, tool calls stream in pieces. On Responses and Messages the whole call arrives at once.
  • Tool results are information, not commands. Kael treats instructions that appear inside a tool result as content to weigh, not orders to follow.