ollama-code

Ollama Code tools

Ollama Code includes built-in tools that the model uses to interact with your local environment, access information, and perform actions. These tools enhance the CLI’s capabilities, enabling it to go beyond text generation and assist with a wide range of tasks.

Overview of Ollama Code tools

In the context of Ollama Code, tools are specific functions or modules that the model can request to be executed. For example, if you ask the model to “Summarize the contents of my_document.txt,” it will likely identify the need to read that file and will request the execution of the read_file tool.

The core component (packages/core) manages these tools, presents their definitions (schemas) to the model, executes them when requested, and returns the results to the model for further processing into a user-facing response.

These tools provide the following capabilities:

How to use Ollama Code tools

To use Ollama Code tools, provide a prompt to the CLI. The process works as follows:

  1. You provide a prompt to the CLI.
  2. The CLI sends the prompt to the core.
  3. The core, along with your prompt and conversation history, sends a list of available tools and their descriptions/schemas to the configured model API.
  4. The model analyzes your request. If it determines that a tool is needed, its response will include a request to execute a specific tool with certain parameters.
  5. The core receives this tool request, validates it, and (often after user confirmation for sensitive operations) executes the tool.
  6. The output from the tool is sent back to the model.
  7. The model uses the tool’s output to formulate its final answer, which is then sent back through the core to the CLI and displayed to you.

You will typically see messages in the CLI indicating when a tool is being called and whether it succeeded or failed.

Security and confirmation

Many tools, especially those that can modify your file system or execute commands (write_file, edit, run_shell_command), are designed with safety in mind. Ollama Code will typically:

It’s important to always review confirmation prompts carefully before allowing a tool to proceed.

Learn more about Ollama Code’s tools

Ollama Code’s built-in tools can be broadly categorized as follows:

Additionally, these tools incorporate: