Skip to content

How the model uses tools

DuckTapeKiller edited this page Sep 13, 2026 · 1 revision

This page follows one request from the moment you press Enter until the model answers, in the four modes where Dive supplies the tools: llama.cpp, LM Studio, Ollama and Cloud. Pi mode runs pi's own agent loop instead; see Pi mode.

The loop

  1. Dive sends the conversation to the model, together with the tools the mode has switched on.
  2. The model either answers or asks for one or more tools.
  3. Dive runs each tool the model asked for and adds the results to the conversation.
  4. The model reads the results and carries on: it answers, or it asks for more tools.

Steps 2 to 4 repeat until the model writes its answer or the tool budget runs out. When the model asks for several tools in one reply, Dive runs them all, and together they count as one round.

Two ways to ask for a tool

  • Native tool calling. Dive sends the tools as structured function definitions, and the model replies with structured tool calls. llama.cpp, LM Studio and Ollama use this while NATIVE TOOL CALLING is on, which it is by default.
  • The text prompt. The system prompt describes each tool with an example, and the model calls one by writing <call:tool_name>{"arg": "value"}</call>. Dive takes the block out of the reply before you see it. Cloud mode always works this way. llama.cpp and LM Studio switch to it when the setting is off or when the server refuses the tools, and Ollama keeps the text prompt in the conversation alongside the native tools.

Tools and skills has the details for each mode.

When no tools are offered

  • The DATABASE switch is on. The answer must come from your library's passages, so the model gets no tools. In Ollama mode this applies to /db and to turns grounded in the library.
  • You used a slash command, in llama.cpp, LM Studio or Cloud mode. Dive runs the tool you named itself and asks the model to answer from its result. See Slash commands.

The tool budget

A request can only use so many rounds of tool calls:

Mode Without Agent Mode With Agent Mode
llama.cpp 6 25 by default, from 1 to 50
LM Studio 6 25 by default, from 1 to 50
Ollama 10 25 by default, from 1 to 50
Cloud 6 25 by default, from 1 to 50

When the budget runs out, Dive stops offering tools and adds this instruction to the conversation: [TOOL BUDGET EXHAUSTED] You have used every allowed tool call for this request. Do not call any more tools. Write your complete final answer now from everything you already found. The thinking panel records it, and the model writes its answer from what it has.

Agent Mode

AGENT MODE and AGENT TOOL BUDGET are on each mode's MAIN tab. Agent Mode changes two things:

  • The budget goes up to 25 by default, as the table shows.
  • The instructions change. Without Agent Mode, the model is steered to answer factual questions with one deep_research call. With it, the model is told to plan first, work one step at a time, never repeat a call that failed with the same arguments, and write the final answer only after its last tool call. In llama.cpp, LM Studio and Cloud mode it keeps the plan as a checklist with the task_plan tool and may send independent calls together. In Ollama mode it writes a short numbered plan in its reasoning.

Tool calls then appear as a step timeline in the chat.

Permission prompts

These tools ask before every run: shell_command, run_code, run_python, macos_control, browse_act, every custom shell tool, and every external tool that sets requiresConfirmation.

The dialog's title names the kind of request: "Shell Command Execution Request", "Code Execution Request", "Python Execution Request", "macOS Control Request", or "Action Request" followed by the tool's name. It shows the command, the code or the arguments, with ALLOW, DENY and CANCEL buttons.

  • ALLOW runs the tool.
  • DENY or CANCEL doesn't run it. The model is told you refused and not to try again.
  • No answer. In every mode the dialog uses the timeout settings on Pi mode's MAIN tab. After PERMISSION DECISION TIMEOUT, 45 seconds by default, Dive applies TIMEOUT DEFAULT ACTION, with a countdown in the dialog until then. With the default action, Deny, the tool doesn't run and the model is told the prompt expired, so it can ask you instead of reporting a refusal you never made. If you set the action to Allow, the tool runs when the time is up. With the timeout set to 0, Dive waits for you, and the server stops waiting after five minutes.

If you close the dialog, the PERMISSION button in the top bar opens it again.

Each request, run, refusal and expiry is written to ~/dive/security-events.jsonl.

Other safety nets

  • A switched-off tool. If the model calls a native tool that is off in this mode, the tool doesn't run. The model is told Tool "name" is disabled in Tools settings. and given the list of tools it can use.
  • Broken arguments. If a tool's arguments aren't valid JSON, Dive doesn't guess: the tool doesn't run, and the model is asked to call it again with a valid JSON object. Valid JSON with a missing field is passed on, and the tool supplies its own default or its own message.
  • Repeated calls. In llama.cpp, LM Studio and Cloud mode, a second call to the same tool with the same arguments (ignoring spaces and letter case) isn't run again. The model is told to answer from the results it already has. task_plan and time_and_date are allowed to repeat.
  • Stray markup. If a model writes tool-call markup into its answer, Dive removes it before showing the text.

What you see

  • While tools run, Dive shows the work in progress. Every call is listed in the collapsible Execution Trace, which is marked when something failed.
  • Web pages and library passages that the answer drew on appear as clickable source pills.
  • When a tool produces an image for the model to look at, such as a browser screenshot, Dive adds it to the conversation after the tool results so a vision model can see it. At most two images are added per round.

For developers

  • The tool loops live in routes/chat.js: handleLocalModeStream() for llama.cpp and LM Studio, and the /api/cloud/chat/stream and /api/chat/stream handlers for Cloud and Ollama.
  • runLocalToolCall() records the trace, applies the repeat guard (tools exempt from it are in REPEATABLE_SKILLS) and calls executeToolCallWithConfirmation().
  • exhaustToolBudget() withdraws the tools and appends the [TOOL BUDGET EXHAUSTED] message.
  • requestShellConfirmation() emits a needs_ui event with the method confirm. The window shows it with askPiPermission() in assets/js/03-theme.js and answers through POST /api/ollama/tool-respond with the request's session id. schedulePiPermissionDecisionTimeout() answers on your behalf with timedOut: true when the decision timeout passes, and a five-minute timer on the server is the backstop.
  • getCloudSkillsPolicyPrompt() writes the research chain or the agent workflow for llama.cpp, LM Studio and Cloud. Ollama's instructions are built in the window, by getOllamaBasePolicyPrompt() and dbOffAgentWorkflow() in assets/js/01-core.js.
  • The argument check is in executeSkill() in skills.js.

Read next

Clone this wiki locally