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
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
- Start with provider-neutral
ChatMessageobjects. - Call
llm.complete_with_tools(messages=..., system=..., tools=...). - If there are tool calls, validate the name and arguments in your application.
- Run the approved tools.
- Append one
AssistantToolCallMessageand oneToolResultMessageper result. - Call again until the model returns final text.
Provider support
Use Model Reference to check
supports_tools before selecting a model for a tool loop.

