nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Usage with local ollama - "Bad request: ... does not support tools"

Open sdbbs opened this issue 11 months ago • 3 comments

Description

I cannot get a local Ollama model to work with nanocoder - writing any prompt fails with "Bad request: ... does not support tools"; I guess I would mostly put this as a documentation bug, as I have very little knowledge about LLM setup, and I never found any docs on how to setup a local Ollama with any model that works, so I just kind of experimented - more details below.

Environment

  • OS: Ubuntu 24.04.3 LTS
  • Node version: v24.12.0
  • Nanocoder version: (run nanocoder --version - that command starts nanocoder fully, does not just output version; from the started nanocoder, I see 1.19.2)
  • Provider: Ollama
  • Model: deepseek-r1:latest

Details

I have intalled Ollama, which claims:

$ ollama --version
ollama version is 0.13.4

Then I installed the deepseek-r1 model within Ollama using ollama pull deepseek-r1; and with that I can see:

$ ollama list
NAME                  ID              SIZE      MODIFIED    
gpt-oss:20b           17052f91a42e    13 GB     2 weeks ago    
deepseek-r1:latest    6995872bfe4c    5.2 GB    2 weeks ago    

(Upon first run of nanocoder set up for Ollama, I think, the gpt-oss:20b got downloaded automatically).

Anyways, when I run the model directly from Ollama, it works:

$ ollama run deepseek-r1
>>> Hello, what is your name?
Thinking...
Okay, the user just asked “Hello, what is your name?” That's a pretty straightforward greeting and 
identity question. 

Hmm, they might be new to chatting with me or just testing the waters. The tone seems friendly but 
neutral - probably not looking for anything too deep right now. 

I should keep it simple but warm. “DeepSeek” is my official name, but “assistant” makes me sound 
less robotic. Adding a smiley might make it feel more human. 

The user didn't specify any task yet, so keeping it open-ended with “I'm here to help” leaves room 
for them to steer the conversation wherever they want. 

No need to overthink this one - just a cheerful introduction should do. If they have something 
specific in mind later, we can dive deeper then.
...done thinking.

Hello! I'm DeepSeek, your friendly AI assistant. 😊 You can just call me Assistant if you prefer. 
How can I help you today?

>>> /bye

Then I had run nanocoder, and ran /setup-config inside it, and it resulted with following agents.config.json:

{
  "nanocoder": {
    "providers": [
      {
        "name": "ollama",
        "models": [
          "deepseek-r1:latest"
        ],
        "baseUrl": "http://localhost:11434/v1"
      }
    ]
  }
}

With that, when I run nanocoder, I can see:

 Status 
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                   │
│  CWD: /LLM                                                                                        │
│  Config: /LLM/agents.config.json                                                                  │
│  Provider: ollama, Model: deepseek-r1:latest                                                      │
│  Theme: Tokyo Night                                                                               │
│  ↳ No AGENTS.md file found, run `/init` to initialize this directory                              │
│  ✓ Preferences loaded                                                                             │
│                                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯

... but when I try to prompt/ask a question:

What would you like me to help with?
> Hello, what is your name? 

▶ normal mode on (Shift+Tab to cycle)

... I get the Bad request error:

You:
Hello, what is your name?

Bad request: registry.ollama.ai/library/deepseek-r1:latest does not support tools

Ok, so this error message puzzled me to no end, since I have no idea what "tools" are, and I couldn't have possibly requested their use?

EDIT: Now this is what I find truly bizarre - I ended up installing LM Studio, and using the same ollama models there; mind you, this deepseek-r1 is the only model there which is tagged as trained for tool use?! WTF?! Are "tools" different in these environments, WTF?! mind = blown:

Image

So I thought I should check what sort of HTTP API requests are being sent; I found https://github.com/Nano-Collective/nanocoder?tab=readme-ov-file#logging-configuration and so I tried:

NANOCODER_LOG_LEVEL=trace NANOCODER_LOG_TO_FILE=true nanocoder

Unlike what the docs say

Default Log File Locations:

When NANOCODER_LOG_TO_FILE=true is set, logs are stored in platform-specific locations:

Linux/Unix: ~/.config/nanocoder/logs/nanocoder/

... my log file ended up in ~/.config/nanocoder/logs/nanocoder-2026-01-02.log - unfortunately there are no HTTP requests logged there.

So, I fired up Wireshark, and finally I could see the actual request being sent:

POST /v1/chat/completions HTTP/1.1
host: localhost:11434
connection: keep-alive
authorization: Bearer dummy-key
content-type: application/json
user-agent: ai/6.0.0-beta.130 ai-sdk/provider-utils/4.0.0-beta.41 runtime/node.js/24
accept: */*
accept-language: *
sec-fetch-mode: cors
accept-encoding: gzip, deflate
content-length: 11655

{"model":"deepseek-r1:latest","messages":[{"role":"system","content":"You are Nanocoder, a terminal-based AI coding agent. Assist with software development tasks using only available tools. NEVER assist with malicious or harmful intent.\n\n## CORE PRINCIPLES\n\n- **Technical accuracy over validation**: Focus on facts, not praise. Disagree when necessary. Investigate uncertainties before confirming beliefs.\n- **Concise and technical**: Clear terminal-friendly responses. No unnecessary superlatives or emojis (unless requested).\n- **Task-focused**: Complete tasks efficiently, avoid prolonged conversation.\n\n## TASK APPROACH\n\n**Questions**: Provide concise instructions. Ask if they want you to perform it.\n\n**Simple tasks**: Be direct. Use judgment for minor details. Run the right command.\n\n**Complex tasks**:\n1. Analyze and set clear goals\n2. Work sequentially using tools\n3. Verify all required parameters before calling tools (never use placeholders)\n4. Present results clearly\n5. Iterate on feedback but avoid pointless back-and-forth\n\n## TOOL USE\n\n**Principles**:\n- Use tools sequentially, informed by previous results\n- Never assume success - verify each step\n- Describe actions, not tool names (\"editing file\" not \"using edit tool\")\n- Use only native tool calling (no text-based formats like `[tool_use]` or `<function>`)\n\n**CRITICAL - Continue after tools**: After any tool execution, immediately proceed to the next step. Don't wait for user input. Tool execution is ongoing work, not a stopping point. Chain your reasoning, stay focused on the goal, and complete thoroughly.\n\n## CONTEXT GATHERING\n\n**Available tools**:\n- **find_files**: Locate files by glob pattern\n- **search_file_contents**: Find code patterns across codebase\n- **read_file**: Read files with progressive disclosure (>300 lines returns metadata first, then use line ranges)\n- **lsp_get_diagnostics**: Check for errors/linting issues (before and after changes)\n- **web_search / fetch_url**: Look up documentation, APIs, and solutions online\n\n**Workflow**: Analyze file structure ... find relevant files ... search for patterns ... read with line ranges ... understand dependencies ... make informed changes\n\n## FILE EDITING\n\n**read_file**: Read with line numbers. Progressive disclosure for large files (>300 lines returns metadata first, then use line ranges). NEVER use cat/head/tail.\n\n**Editing tools** (always read_file first):\n- **write_file**: Write entire file (creates new or overwrites existing) - use for new files, complete rewrites, generated code, or large changes\n- **string_replace**: PRIMARY EDIT TOOL - Replace exact string content (handles replace/insert/delete operations)\n\n**Tool selection guide**:\n- Small edits (1-20 lines): Use `string_replace`\n- Large rewrites (>50% of file): Use `write_file`\n- Generated code/configs: Use `write_file`\n\n**string_replace workflow**:\n1. Read file to see current content\n2. Copy EXACT content to replace (including whitespace, indentation, newlines)\n3. Include 2-3 lines of surrounding context for unique matching\n4. Specify new content (can be empty to delete)\n\n**CRITICAL - Make granular, surgical edits**:\n- Use `string_replace` for targeted changes (typically 1-20 lines)\n- Use `write_file` for large rewrites (>50% of file or generated code)\n- Include enough context in string_replace to ensure unique matching\n- Why: Self-verifying (fails if file changed), no line number tracking, clearer intent, matches modern tools (Cline, Aider)\n- Both tools return the actual file contents after write for verification\n\n## TERMINAL COMMANDS (execute_bash)\n\n**Critical rules**:\n- NEVER read or edit files via terminal (use dedicated tools)\n- No malicious/harmful commands\n- Avoid unsafe commands unless explicitly necessary\n- Don't use echo for output (respond directly to user)\n\n**Key points**:\n- Consider OS/shell compatibility\n- Can't cd permanently (use `cd /path && command` for single commands)\n- Interactive and long-running commands allowed\n- If no output appears, assume success and proceed\n- Explain what commands do\n\n## CODING PRACTICES\n\n- **Understand before editing**: ALWAYS read files before modifying. Never blindly suggest edits.\n- **Manage dependencies**: Update upstream/downstream code. Use search_file_contents to find all references.\n- **Match existing style**: Follow project patterns, idioms, and standards even if they differ from best practices.\n- **Respect project structure**: Check manifest files (package.json, requirements.txt), understand dependencies, follow project-specific conventions.\n- **New projects**: Organize in dedicated directory, structure logically, make easy to run.\n\n## EXECUTION WORKFLOW\n\n1. **Understand**: Analyze request, identify goals, determine needed context\n2. **Gather context**: Find files, search patterns, read relevant code\n3. **Execute step-by-step**: Sequential tools informed by previous results. Verify each step.\n4. **Report findings**: State what you discover (not assumptions). Investigate unexpected results.\n5. **Complete thoroughly**: Address all aspects, verify changes, consider downstream effects\n\n## ASKING QUESTIONS\n\n**Ask when**: Genuine ambiguities, missing required parameters, complex intent clarification needed\n\n**Don't ask when**: Minor details (use judgment), answers findable via tools, info already provided, sufficient context exists\n\n**How**: Be specific, concise, explain why if not obvious. Balance thoroughness with efficiency.\n\n## CONSTRAINTS\n\n- **Environment**: Fixed cwd. Use `cd /path && command` for one-off directory changes. No ~ or $HOME.\n- **File ops**: Always use dedicated tools, never terminal commands. Read before editing. Account for auto-formatting.\n- **Commands**: Tailor to user's OS/shell. Explain purpose. Avoid unsafe commands.\n- **Completion**: Work systematically, continue after tools, present results, minimize unnecessary conversation.\n- **Error handling**: Assume success if no error shown. Investigate failures. Verify with tools, not assumptions.\n\n## SYSTEM INFORMATION\n\nOperating System: Linux\nOS Version: 6.8.0-90-generic\nPlatform: linux\nDefault Shell: /bin/bash\nHome Directory: /home/administrator\nCurrent Working Directory: /LLM\nCurrent Date: 2026-01-02\nCurrent Time: 14:01:18\n"},{"role":"user","content":"Hello, what is your name"}],"tools":[{"type":"function","function":{"name":"read_file","description":"Read file contents with line numbers. PROGRESSIVE DISCLOSURE: First call without line ranges returns metadata (size, lines, tokens). For files >300 lines, you MUST call again with start_line/end_line to read content. Small files (<300 lines) return content directly.","parameters":{"type":"object","properties":{"path":{"type":"string","description":"The path to the file to read."},"start_line":{"type":"number","description":"Optional: Line number to start reading from (1-indexed). Required for files >300 lines. Use with end_line to read specific range."},"end_line":{"type":"number","description":"Optional: Line number to stop reading at (inclusive). Required for files >300 lines. Use with start_line to read specific range."}},"required":["path"]}}},{"type":"function","function":{"name":"write_file","description":"Write content to a file (creates new file or overwrites existing file). Use this for complete file rewrites, generated code, or when most of the file needs to change. For small targeted edits, use string_replace instead.","parameters":{"type":"object","properties":{"path":{"type":"string","description":"The path to the file to write."},"content":{"type":"string","description":"The complete content to write to the file."}},"required":["path","content"]}}},{"type":"function","function":{"name":"string_replace","description":"Replace exact string content in a file. IMPORTANT: Provide exact content including whitespace and surrounding context. For unique matching, include 2-3 lines before/after the change. Break large changes into multiple small replacements.","parameters":{"type":"object","properties":{"path":{"type":"string","description":"The path to the file to edit."},"old_str":{"type":"string","description":"The EXACT string to find and replace, including all whitespace, newlines, and indentation. Must match exactly. Include surrounding context (2-3 lines) to ensure unique match."},"new_str":{"type":"string","description":"The replacement string. Can be empty to delete content. Must preserve proper indentation and formatting."}},"required":["path","old_str","new_str"]}}},{"type":"function","function":{"name":"execute_bash","description":"Execute a bash command and return the output (use for running commands)","parameters":{"type":"object","properties":{"command":{"type":"string","description":"The bash command to execute."}},"required":["command"]}}},{"type":"function","function":{"name":"web_search","description":"Search the web for information (scrapes Brave Search, returns markdown)","parameters":{"type":"object","properties":{"query":{"type":"string","description":"The search query."},"max_results":{"type":"number","description":"Maximum number of search results to return (default: 10)."}},"required":["query"]}}},{"type":"function","function":{"name":"fetch_url","description":"Fetch and parse markdown content from a URL","parameters":{"type":"object","properties":{"url":{"type":"string","description":"The URL to fetch content from."}},"required":["url"]}}},{"type":"function","function":{"name":"find_files","description":"Find files and directories by path pattern or name. Use glob patterns like \"*.tsx\", \"**/*.ts\", \"src/**/*.js\", or \"*.{ts,tsx}\". Returns a list of matching file and directory paths. Does NOT search file contents - use search_file_contents for that.","parameters":{"type":"object","properties":{"pattern":{"type":"string","description":"Glob pattern to match file and directory paths. Examples: \"*.tsx\" (all .tsx files), \"src/**/*.ts\" (all .ts in src/), \"components/**\" (all files/dirs in components/), \"*.{ts,tsx}\" (multiple extensions)"},"maxResults":{"type":"number","description":"Maximum number of results to return (default: 50, max: 100)"}},"required":["pattern"]}}},{"type":"function","function":{"name":"search_file_contents","description":"Search for text or code INSIDE file contents. Returns file paths with line numbers and matching content. Use this to find where specific code, functions, variables, or text appears in the codebase. Supports extended regex patterns.","parameters":{"type":"object","properties":{"query":{"type":"string","description":"Text or code to search for inside files. Supports extended regex (e.g., \"foo|bar\" for alternation, \"func(tion)?\" for optional groups). Examples: \"handleSubmit\", \"import React\", \"TODO|FIXME\", \"class\\s+\\w+\". Search is case-insensitive by default."},"maxResults":{"type":"number","description":"Maximum number of matches to return (default: 30, max: 100)"},"caseSensitive":{"type":"boolean","description":"Whether to perform case-sensitive search (default: false)"}},"required":["query"]}}},{"type":"function","function":{"name":"lsp_get_diagnostics","description":"Get errors and warnings for a file or project from the language server. Returns type errors, linting issues, and other diagnostics. Use this to check for problems before or after making code changes.","parameters":{"type":"object","properties":{"path":{"type":"string","description":"Optional path to a specific file. If omitted, returns diagnostics for all open documents."}},"required":[]}}}],"tool_choice":"auto"}

... and finally I get it - there is an entry "tools" in the sent POST data with contents like [{"type":"function","function":{"name":"read_file","description":"Read file contents with line numbers. ...; these are most likely part of "Built-in tools: File operations, bash command execution" of nanocoder.

Turns out, the README.md also mentions:

Plan mode: AI suggests actions but doesn't execute tools - useful for planning and exploration

... and I tried cycling through to "Plan mode" and issuing the prompt again - but still got the "Bad request" error.

Another weird thing, is that looking at https://registry.ollama.ai/library/deepseek-r1, this model is tagged with "tools"; so I cannot really use that tag on that page to look up models that support "tools" for use with nanocoder.

So, I guess, this resolves to two main questions:

  • How do I find Ollama models that support "tools" for use with nanocoder? (given that the most obvious answer, "look in registry.ollama.ai for models tagged with 'tools'", does not quite work)
  • If I have a model that does not support "tools", how can I disable calling "tools" from nanocoder so I can chat with the model? (given that the most obvious answer, "Use plan mode which does not execute tools" does not quite work either, since that apparently still sends the "tools" parameter with the POST request)

sdbbs avatar Jan 02 '26 13:01 sdbbs

Ok, I found ollama 0.2.7 function call error "llama3 does not support tools" · Issue #5793 · ollama/ollama which mentions:

https://ollama.com/library/llama3-groq-tool-use supports tool use. I just filed https://github.com/ollama/ollama/issues/5794 to expose the capabilities of a model.

So I did this:

# to install:
$ ollama pull llama3-groq-tool-use:8b

# check
$ ollama list
NAME                       ID              SIZE      MODIFIED       
llama3-groq-tool-use:8b    36211dad2b15    4.7 GB    18 seconds ago    
gpt-oss:20b                17052f91a42e    13 GB     2 weeks ago       
deepseek-r1:latest         6995872bfe4c    5.2 GB    2 weeks ago       

$ ollama run llama3-groq-tool-use

Inside ollama, chatting with this model felt quite snappy for the 8GB RAM and no graphics card that I have on this machine. Then I changed the agents.config.json file to this:

{
  "nanocoder": {
    "providers": [
      {
        "name": "ollama",
        "models": [
          "llama3-groq-tool-use:8b"
        ],
        "baseUrl": "http://localhost:11434/v1"
      }
    ]
  }
}

... and then I started nanocoder; I could notice that chatting with this model in nanocoder is A LOT SLOWER - it took like 10 minutes or thereabouts to complete the answer to "Hello, what is your name?" - probably because nanocoder sends a lot of context in its POST request.

In any case, I can finally see that the system works with at least one model, which is great!

sdbbs avatar Jan 02 '26 14:01 sdbbs

That is because the models you have selected is too simple, which cannot use the tools

Suitable model:

Devstral-2 Qwen3-coder gpt:oss

Etc

jason1015-coder avatar Jan 05 '26 09:01 jason1015-coder

Did you figure anything out related to the tags? IT would be nice to see more support with nanacoder as it relates to lmstudio instead of ollama.

linuxcube avatar Feb 15 '26 22:02 linuxcube