documentation/docs/guides/tool-shim.md
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
:::warning Experimental Feature The tool shim is an experimental feature. Configuration options and behavior may change in future releases. :::
Some language models don't natively support tool/function calling, or intermittently output tool calls as plaintext instead of structured API responses. The tool shim detects these text-based tool call formats and converts them into proper tool calls that goose can execute.
Enable the tool shim when:
functions.shell:0 <|tool_call_argument_begin|> {...} instead of using the tool API<think>) with tool calls, causing parsing failuresMost locally-hosted models and some cloud models that weren't fine-tuned for structured tool calling will need the shim.
The shim intercepts model responses and converts any text-based tool call formats into structured tool calls that goose can execute. It requires a separate interpreter model — by default, goose uses Ollama for this. The interpreter model is independent of whichever provider you use for your main conversation.
export GOOSE_TOOLSHIM=true
Ollama must be installed and running. The default interpreter model is mistral-nemo.
# Pull the default interpreter model
ollama pull mistral-nemo
# Optional: use a different interpreter model
export GOOSE_TOOLSHIM_OLLAMA_MODEL=llama3.2
If you're running goose with the built-in local inference backend, you can use it as the interpreter instead of a separate Ollama instance. A model name is required — set either GOOSE_TOOLSHIM_MODEL or the LOCAL_LLM_MODEL config key, otherwise goose will error on startup:
export GOOSE_TOOLSHIM_BACKEND=local
export GOOSE_TOOLSHIM_MODEL=my-model-name
Valid values for GOOSE_TOOLSHIM_BACKEND: ollama (default), local, llama.cpp.
GOOSE_TOOLSHIM=true goose session
Uses mistral-nemo as the interpreter. Override with GOOSE_TOOLSHIM_OLLAMA_MODEL if needed.
GOOSE_TOOLSHIM=true \
GOOSE_TOOLSHIM_OLLAMA_MODEL=llama3.2 \
goose session
Your primary provider can be anything (Bedrock, a custom router, etc.). The shim uses Ollama locally as the interpreter regardless of which provider you're talking to.
</TabItem> <TabItem value="local-backend" label="Built-in local inference">GOOSE_TOOLSHIM=true \
GOOSE_TOOLSHIM_BACKEND=local \
GOOSE_TOOLSHIM_MODEL=my-model-name \
goose session
Uses goose's built-in llama.cpp backend as the interpreter. GOOSE_TOOLSHIM_MODEL (or LOCAL_LLM_MODEL in config) is required — startup fails if neither is set.
| Variable | Description | Default |
|---|---|---|
GOOSE_TOOLSHIM | Enable the tool shim (true or 1) | false |
GOOSE_TOOLSHIM_BACKEND | Interpreter backend: ollama, local, or llama.cpp | ollama |
GOOSE_TOOLSHIM_OLLAMA_MODEL | Ollama model used as the interpreter | mistral-nemo |
GOOSE_TOOLSHIM_MODEL | Model name for the local interpreter backend (required if using local backend and LOCAL_LLM_MODEL config is not set) | — |
Tools suddenly stop working in the middle of a session
The model may have switched from native tool calls to a text-based format. Enable GOOSE_TOOLSHIM=true and restart.
The shim is enabled but tools still don't execute
Check that your interpreter backend is reachable:
ollama list to confirm it's running and the interpreter model is pulled.Interpreter calls are slow
Switch to a smaller, faster Ollama model:
export GOOSE_TOOLSHIM_OLLAMA_MODEL=qwen2.5:3b
Model outputs reasoning before tool calls (<think> tags)
Some reasoning models mix thinking tags with tool calls, causing parsing failures. The shim handles this automatically — enable it and the reasoning content is stripped from the final message.