Skip to main content
Ragrails exposes tool calling at the LLM provider layer through complete_with_tools(). This is the lower-level mechanism used by the interactive CLI’s agentic tools. Use this page when you are building your own tool loop. Use Agentic Tools when you want the ready-made interactive CLI experience. Tool calling is separate from Streaming: streamed chat events do not execute custom tools for you.

Why tools are not automatic in rag.chat()

Built-in tools are not automatically available through SDK rag.chat() because tool execution is not just model output. A real application must decide: The SDK gives you provider-neutral tool calls with complete_with_tools(). Your app validates and runs the tools, then feeds results back to the model.

Core API

SDK
Call complete_with_tools() again after appending tool results. Continue until response.tool_calls is empty.

Provider-neutral types

Tool schema shape

Ragrails uses provider-neutral tool definitions and each provider adapter converts them to its own wire format.

Loop pattern

  1. Start with provider-neutral ChatMessage objects.
  2. Call llm.complete_with_tools(messages=..., system=..., tools=...).
  3. If there are tool calls, validate the name and arguments in your application.
  4. Run the approved tools.
  5. Append one AssistantToolCallMessage and one ToolResultMessage per result.
  6. Call again until the model returns final text.
Ragrails does not execute your custom tools for you at this layer. Your application owns validation, authorization, confirmation, side effects, rate limits, and audit logging.

Provider support

Use Model Reference to check supports_tools before selecting a model for a tool loop.

Relation to chat