Agent Tools

Enable agent mode to let your assistant call tools, search knowledge, and create tickets autonomously during conversations.

What is Agent Mode?

By default, Kody operates as a simple chat proxy: it sends the user's message to your AI backend with a system prompt and streams back the response. Agent mode upgrades this to a tool-calling loop where the AI can autonomously decide to call tools, process their results, and continue generating a response.

When agent mode is enabled and your AI backend supports function calling, the flow becomes:

  1. User sends a message
  2. The AI generates a response, optionally requesting tool calls
  3. If tool calls are requested, Kody executes them and feeds the results back to the AI
  4. The AI continues generating, possibly calling more tools
  5. Once the AI produces a final text response (no more tool calls), it is streamed to the user

A circuit breaker limits the maximum number of tool calls per message (configurable via tools.maxToolCalls, default 5) to prevent runaway loops.

Built-in Tools

Kody provides two built-in tools that are automatically available when their prerequisites are met:

knowledge_search

Searches your knowledge base using RAG (retrieval-augmented generation). The AI decides when to search based on the user's question, rather than always injecting all knowledge into every message.

Auto-enabled when: tools.builtinTools.knowledgeSearch is true (default) and RAG is configured with indexed chunks.

create_ticket

Creates support tickets via your configured ticket providers (Jira, GitHub, Linear, email, webhook). The AI collects the required information conversationally ("What's your email?") and calls the tool when ready, instead of showing a static form.

Auto-enabled when: tickets.enabled is true and at least one ticket provider is configured. See Ticket Providers.

Custom Tools

Define custom tools that call your own HTTP endpoints. The AI decides when to use them based on the tool description and the conversation context.

FieldTypeDescription
namestringTool identifier. Lowercase with underscores only (^[a-z_][a-z0-9_]*$). 1-64 chars.
descriptionstringWhat the tool does. The AI reads this to decide when to use the tool. 1-1000 chars. Be specific.
parametersobjectJSON Schema object describing the tool's input parameters. Each property has a type (string, number, boolean, integer) and optional description and enum.
endpoint.urlstring (URL)The HTTP endpoint Kody calls when the AI invokes this tool.
endpoint.methodenumHTTP method: GET, POST, PUT, or PATCH. Default: POST.
endpoint.headersRecordCustom headers (e.g. Authorization). Stored server-side only.
endpoint.timeoutMsintegerRequest timeout in milliseconds. Range: 1000-30000. Default: 10000.

When the AI calls a custom tool, Kody sends a POST request to the endpoint with this body:

{
  "tool": "order_lookup",
  "arguments": {
    "order_id": "ORD-12345"
  }
}

Your endpoint should return a JSON response. The response body is passed back to the AI as the tool result.

Example: Order Lookup Tool

Here is a complete example of a custom tool that lets the AI look up order status:

{
  "tools": {
    "enabled": true,
    "maxToolCalls": 5,
    "builtinTools": {
      "knowledgeSearch": true
    },
    "customTools": [
      {
        "name": "order_lookup",
        "description": "Look up the status of a customer order by order ID. Use this when a customer asks about their order status, shipping, or delivery.",
        "parameters": {
          "type": "object",
          "properties": {
            "order_id": {
              "type": "string",
              "description": "The order ID (e.g. ORD-12345)"
            }
          },
          "required": ["order_id"]
        },
        "endpoint": {
          "url": "https://api.example.com/orders/lookup",
          "method": "POST",
          "headers": {
            "Authorization": "Bearer your-api-token"
          },
          "timeoutMs": 5000
        }
      }
    ]
  }
}

With this configuration, when a user asks "Where is my order ORD-12345?", the AI will call the order_lookup tool, receive the order data from your API, and respond with a natural language summary of the order status.

Widget UI

When the AI calls a tool, users see a compact status indicator in the chat (not a message bubble):

  • In progress: A small spinner with descriptive text (e.g. "Searching knowledge base...", "Looking up order...")
  • Completed: The spinner becomes a checkmark and the indicator fades slightly

Tool indicators are ephemeral — they are not stored in the conversation history and do not persist across page reloads. The final AI response (which incorporates tool results) is what gets saved.

Capability Detection

Kody automatically probes your AI backend to detect whether it supports tool calling and embeddings. Results are cached for 1 hour per backend. If your backend does not support tools, Kody falls back gracefully:

Backend supportsBehavior
Tools + EmbeddingsFull agent mode: tool calling loop with RAG via knowledge_search tool
Embeddings onlyRAG mode: relevant chunks are injected per-message based on the query
NeitherContext stuffing: all knowledge is injected into the system prompt (original behavior)
No configuration needed: This fallback happens automatically. You can enable tools.enabled and knowledge.rag.enabled regardless of your backend's capabilities — Kody will use the best mode available.

Configuration Reference

The full tools config object:

FieldTypeDefaultDescription
enabledbooleanfalseEnable agent mode with tool calling.
maxToolCallsinteger5Maximum tool calls per message. Range: 1-10. Prevents runaway loops.
builtinTools.knowledgeSearchbooleantrueEnable the knowledge_search built-in tool (requires RAG to be configured).
customToolsarray[]Array of custom tool definitions. See Custom Tools section above.