continue icon indicating copy to clipboard operation
continue copied to clipboard

Ollama models with tools capability unable to read linked / indexed files possibly due to indexing

Open Octanoz opened this issue 1 year ago • 6 comments

Before submitting your bug report

Relevant environment info

- OS: Win11
- Continue version: 0.8.68
- IDE version: VS Code 1.97.2
- Model: Llama3.1, home grown
- config:
  
%YAML 1.1
---

name: standard-config
version: 0.0.2

ollama_defaults: &ollama_defaults
  provider: ollama
  apiBase: http://localhost:11434

ac_model: &ac_model
  defaultCompletionOptions:
      temperature: 0.1
      mirostat: 2

regular_model: &regular_model
  defaultCompletionOptions:
      temperature: 0.4
      mirostat: 2
  roles:
      - chat
      - edit
      - apply

ice_cold: &ice_cold
  defaultCompletionOptions:
      temperature: 0
      mirostat: 2
  roles:
      - chat
      - edit
      - apply

creative_model: &creative_model
  defaultCompletionOptions:
      temperature: 0.7
      mirostat: 0
  roles:
      - chat
      - edit
      - apply

models:
  - name: Llama3.1
    <<: *ollama_defaults
    model: llama3.1
    <<: *regular_model

  - name: DeepSeek-R1-Llama3
    <<: *ollama_defaults
    model: deepseek-r1:8b
    <<: *creative_model

  - name: DeepSeek-R1-Qwen2.5
    <<: *ollama_defaults
    model: deepseek-r1:7b
    <<: *regular_model

  - name: DeepSeek-Coder
    <<: *ollama_defaults
    model: deepseek-coder:6.7b
    <<: *ice_cold

  - name: Open Thinker
    <<: *ollama_defaults
    model: openthinker
    <<: *creative_model

  - name: Qwen-2.5-Coder
    <<: *ollama_defaults
    model: qwen2.5-coder
    <<: *regular_model

  - name: Winnie the Pooh
    <<: *ollama_defaults
    model: yi-coder
    <<: *ice_cold

  - name: Qwen-2.5 AC
    <<: *ollama_defaults
    model: qwen2.5-coder:3b
    <<: *ac_model

  - name: Llama3.2
    <<: *ollama_defaults
    model: Llama3.2
    <<: *ac_model

  - name: StarCoder AC
    <<: *ollama_defaults
    model: starcoder2
    <<: *ac_model
  
  - name: Nomic Embed
    <<: *ollama_defaults
    model: nomic-embed-text
    role:
      - embed
      
context:
  - provider: code
  
  - provider: docs
  
  - provider: diff
  
  - provider: terminal
  
  - provider: problems
  
  - provider: folder
  
  - provider: codebase
  
rules:
    - When writing C# always prefer explicit typing if you are instantiating a collection or a class from a constructor. Only use var when using a method or LINQ to generate the object.
    - When writing F# try to facilitate the use of pipes and prefer pattern matching over if-else unless you're evaluating a boolean statement.
prompts:
  - name: check
    description: Check for mistakes in my code
    prompt: |
      Please read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:
        - Syntax errors
        - Logic errors
        - Security vulnerabilities
        - Performance issues
        - Anything else that looks wrong

      Once you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found.
  - name: test
    description: Write unit tests for the highlighted code
    prompt:  |
      Write a comprehensive set of unit tests for the selected code. Make sure that for C# and F# the tests are written using the Xunit library. Setup and run tests that check for correctness including important edge
      cases, and teardown. Ensure that the tests are complete and sophisticated.
      Give the tests just as chat output, don't edit any file.
docs:
  - name: F# Language Reference
    startUrl: https://learn.microsoft.com/en-gb/dotnet/fsharp/language-reference/
  - name: F# Core Library Docs
    startUrl: https://fsharp.github.io/fsharp-core-docs/

Description

I noticed that the models with tools on Ollama that I'm using, Llama3.1 and Qwen2.5-coder, tend to get this infinite loading spinner and the message: "Continue wants to read filename" with the read permission set to automatic.

I did notice that there was a message in early january saying that currently only Claude Sonnet is supported as model using tools. Is that still the case?

In case it isn't I did have a look at the dev tools of VS Code and I noticed it seems to be looking in the c folder for the file. Perhaps it could've found it if it went to the C: drive instead... In this case the :\ came before the drive. Possible indexing / parsing bug? Everything has just been newly indexed after the previously cache was lost when I switched to the yaml config file.

I believe the below shows me actively linking with @Files -> filename in the top 2 messages and the last one is the extension pro-actively reading what's open on the screen. But there as well, the actual relative path from the solution folder to that file would be 2 folders down (i.e. InputFiles/Day12/)

log.ts:456   ERR [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "e552fdc2-d5d1-47b1-8128-9a0ae23c1fc9",
    "messageType": "tools/call",
    "data": {
      "toolCall": {
        "id": "",
        "type": "function",
        "function": {
          "name": "builtin_read_file",
          "arguments": "{\"filepath\":\"/c/Users/etc/instructions.md\"}"
        }
      },
      "selectedModelTitle": "Llama3.1"
    }
  }
}
Error: Could not find file /c/Users/etc/instructions.md
error @ log.ts:456
console.ts:137 [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "e552fdc2-d5d1-47b1-8128-9a0ae23c1fc9",
    "messageType": "tools/call",
    "data": {
      "toolCall": {
        "id": "",
        "type": "function",
        "function": {
          "name": "builtin_read_file",
          "arguments": "{\"filepath\":\"/c/Users/etc/instructions.md\"}"
        }
      },
      "selectedModelTitle": "Llama3.1"
    }
  }
Error: Could not find file /c/Users/etc/instructions.md
Ats @ console.ts:137
index.js:545 Received streamed tool call response prior to initial tool call delta
streamUpdate @ index.js:545
log.ts:456   ERR [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "f41952ee-be98-40e3-accc-4cd8ac342b95",
    "messageType": "tools/call",
    "data": {
      "toolCall": {
        "id": "",
        "type": "function",
        "function": {
          "name": "builtin_read_file",
          "arguments": "{\"filepath\":\"instructions.md\"}"
        }
      },
      "selectedModelTitle": "Llama3.1"
    }
  }
}
Error: Could not find file instructions.md
error @ log.ts:456
console.ts:137 [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "f41952ee-be98-40e3-accc-4cd8ac342b95",
    "messageType": "tools/call",
    "data": {
      "toolCall": {
        "id": "",
        "type": "function",
        "function": {
          "name": "builtin_read_file",
          "arguments": "{\"filepath\":\"instructions.md\"}"
        }
      },
      "selectedModelTitle": "Llama3.1"
    }
  }
}

Error: Could not find file instructions.md
}

To reproduce

  1. Open chat session.
  2. Give some instructions while also linking a currently open file with @Files
  3. Infinite spinner "Continue wants to read X"
  4. Patiently stare at the spinner for the rest of the day

Log output


Octanoz avatar Feb 26 '25 15:02 Octanoz

I am experiencing exactly this as well.

Using ollama / qwen2.5-coder:32b

weignerg avatar Feb 26 '25 17:02 weignerg

This may not be all of the problem, but I noticed that it seems that in order to get good responses we need to set the ctx_num higher from the default that is set for the ollama model.

Roo Code - Providers / Ollama

Configure the Model: by default, Ollama uses a context window size of 2048 tokens, which is too small for Roo Code requests. You need to have at least 12k to get decent results, ideally - 32k. To configure a model, you actually need to set its parameters and save a copy of it.

Load the model (we will use qwen2.5-coder:32b as an example):

ollama run qwen2.5-coder:32b

Change context size parameter:

/set parameter num_ctx 32768

Save the model with a new name:

/save your_model_name

weignerg avatar Feb 27 '25 18:02 weignerg

This may not be all of the problem, but I noticed that it seems that in order to get good responses we need to set the ctx_num higher from the default that is set for the ollama model.

@weignerg you can use the maxTokens setting for that: https://docs.continue.dev/json-reference

tomasz-stefaniak avatar Mar 03 '25 21:03 tomasz-stefaniak

Thanks for answering weignerg about my question, I suppose... It's not possible to change the maxTokens alone without having the UI yell at you that this can't work with the current context length. There are only vague indicators in the docs about how the context is used by default. If I'm not mistaken the rules section of the config.yaml is also part of the context so are we just to attempt some trial and error with contextLength and maxTokens to find the sweet spot between performance and getting yelled at by the UI or are there recommendations / best practices I've missed?

Octanoz avatar Mar 09 '25 11:03 Octanoz

@Octanoz I agree that we should most likely make it more clear in our docs (we have lots of docs work to do in general). Regarding your question, yes, you will most likely need to decide by trial and error. The UI yelling at you is not arbitrary - it is a limitation of most models that maxTokens cannot exceed contextLength.

tomasz-stefaniak avatar Mar 11 '25 16:03 tomasz-stefaniak

@Octanoz I agree that we should most likely make it more clear in our docs (we have lots of docs work to do in general). Regarding your question, yes, you will most likely need to decide by trial and error. The UI yelling at you is not arbitrary - it is a limitation of most models that maxTokens cannot exceed contextLength.

Ok, thanks a million for confirming.

Octanoz avatar Mar 11 '25 16:03 Octanoz