Skip to content

code review如何通过本地模型review #234

Closed

Description

@semi-xi

Issue Type

Incorrect information

Document Location

https://github.com/alibaba/open-code-review/blob/main/README.zh-CN.md

Description

模型列表如下

 ollama list
NAME                  ID              SIZE      MODIFIED          
qwen2.5-coder:14b     9ec8897f747e    9.0 GB    About an hour ago    
ds14b-large:latest    bde73b1178d2    9.0 GB    2 hours ago          
deepseek-r1:32b       edba8017331d    19 GB     3 hours ago          
deepseek-r1:14b       c333b7232bdb    9.0 GB    16 hours ago   

配置是通过这样配置的,最后测试连通,也通过了

 ocr config provider

Provider set to: my-llm (custom)
Model: qwen2.5-coder:14b

Testing connection...
Source: provider:my-llm
URL:    http://127.0.0.1:11434/v1
Model:  qwen2.5-coder:14b
I am an AI-powered code review

现在需要review的是前端项目
执行

ocr review \
  --from master \
  --to feature/xxxxx \
  --concurrency 2 \
  --timeout 1

无论是用qwen2.5-coder还是用deepseek-r1:32b或者deepseek-r1:14b执行都会出现以下异常(无论是.json还是.tsx)

[ocr] No tool calls parsed for .eslintrc.json, retrying...
[ocr] No tool calls parsed for .eslintrc.json, retrying...
[ocr] No tool calls parsed for .eslintrc.json, retrying...
[ocr] No tool calls parsed for .eslintrc.json, retrying...

是模型有什么问题?还是需要指定模型吗?

Suggested Change

No response

Activity

  1. added
    documentation
    on Jun 27, 2026
  2. semi-xi commented on Jun 27, 2026

    @semi-xi
    Author
    [ocr] Skipping plan phase for src/bizComponent/AddressIconItem/index.tsx (13 lines < threshold 50)
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] No tool calls parsed for src/bizComponent/AddressIconItem/index.tsx, retrying...
    [ocr] Max tool requests reached for src/bizComponent/AddressIconItem/index.tsx.
    
  3. lizhengfeng101 commented on Jun 27, 2026

    @lizhengfeng101
    Contributor

    你好!感谢反馈这个问题。

    原因分析

    "No tool calls parsed" 的根本原因是:你使用的本地模型不支持(或不能可靠支持)OpenAI 格式的原生 Tool Calling(Function Calling)。

    OCR 的工作机制是通过 OpenAI 兼容 API 的 tools 参数向模型发送工具定义(如 code_comment、task_done 等),并期望模型在响应的 tool_calls 结构化字段中返回工具调用。但像 qwen2.5-coder:14b、deepseek-r1:14b/32b 这类模型,虽然 Ollama 提供了 OpenAI 兼容的 API 端点,Tool Calling 能力取决于底层模型本身是否经过 Function Calling 微调。这些模型在收到工具定义后,通常会把工具调用以纯文本形式输出在 content 字段中,而不是放在 API 响应的 tool_calls 字段里,导致 OCR 无法解析,从而不断重试。

    解决建议

    建议更换为支持原生 Tool Calling 的模型。以下是一些通过 Ollama 可用且支持原生 Tool Calling 的推荐模型:

    模型 尺寸 说明
    qwen3:32b 20GB Qwen3 系列,原生支持 Tool Calling
    qwen3:14b 9.4GB 适合显存有限的环境
    qwen3:8b 5.2GB 轻量级,适合入门
    MFDoom/deepseek-r1-tool-calling:32b 19GB 专门针对 Tool Calling 微调的 DeepSeek R1

    安装示例:

    ollama pull qwen3:32b

    然后重新配置 OCR:

    ocr config provider
    # 选择 custom,设置模型为 qwen3:32b

    注意:deepseek-r1 原版是纯推理模型,没有经过 Function Calling 微调,所以天然不支持 Tool Calling。qwen2.5-coder 的 Tool Calling 支持也不够稳定。建议优先选择 Qwen3 系列模型。

    如果更换模型后仍然遇到问题,请告知我们,我们会进一步排查。

  4. semi-xi commented on Jun 28, 2026

    @semi-xi
    Author
    Provider set to: my-llm2 (custom)
    Model: qwen3:32b
    
    Testing connection...
    Source: provider:my-llm2
    URL:    http://127.0.0.1:11434/v1
    Model:  qwen3:32b
    I am open-code-review, a code review assistant developed by Alibaba, designed to run in your command-line environment.
    ✓ Connection test successful
    
    Tip: run 'ocr config model' to switch model later.
    
    ocr config model
    Model set to: qwen3:32b
    

    按照以下命令执行

    ocr review \
      --from master \
      --to feature/20260709_4818_cross \
      --concurrency 1
    

    输出结果

    ocr] Subtask error for .eslintrc.json: LLM completion error: context deadline exceeded
    [ocr] Skipping plan phase for .gitignore (5 lines < threshold 50)
    [ocr] No tool calls parsed for .gitignore, retrying...
    [ocr] Skipping plan phase for openspec/changes/customs/.openspec.yaml (2 lines < threshold 50)
    [ocr] No tool calls parsed for openspec/changes/customs/.openspec.yaml, retrying...
    [ocr] Skipping plan phase for openspec/config.yaml (20 lines < threshold 50)
    [ocr] No tool calls parsed for openspec/config.yaml, retrying...
    [ocr] Skipping plan phase for override.config.js (7 lines < threshold 50)
    [ocr] Subtask error for override.config.js: LLM completion error: context deadline exceeded
    [ocr] Skipping plan phase for package.json (20 lines < threshold 50)
    

    另外一个模型

    Provider set to: my-llm3 (custom)
    Model: MFDoom/deepseek-r1-tool-calling:32b
    
    Testing connection...
    Source: provider:my-llm3
    URL:    http://127.0.0.1:11434/v1
    Model:  MFDoom/deepseek-r1-tool-calling:32b
    open-code-review is a command-line tool developed by Alibaba to facilitate code reviews.
    ✓ Connection test successful
    
    Tip: run 'ocr config model' to switch model later.
    

    输出的结果

    [ocr] Skipping yarn.lock — filtered by path/extension rules
    [ocr] Filtered 41 file(s) by include/exclude rules
    [ocr] Skipping plan phase for .eslintrc.json (13 lines < threshold 50)
    [ocr] No tool calls parsed for .eslintrc.json, retrying...
    [ocr] No tool calls parsed for .eslintrc.json, retrying...
    [ocr] No tool calls parsed for .eslintrc.json, retrying...
    [ocr] No tool calls parsed for .eslintrc.json, retrying...
    [ocr] Subtask error for .eslintrc.json: LLM completion error: context deadline exceeded
    [ocr] Skipping plan phase for .gitignore (5 lines < threshold 50)
    
    

    尝试过了也是一样,我的配置是M1pro 32GB+1TB

    @lizhengfeng101

  5. semi-xi commented on Jun 29, 2026

    @semi-xi
    Author

    你好!感谢反馈这个问题。

    原因分析

    "No tool calls parsed" 的根本原因是:你使用的本地模型不支持(或不能可靠支持)OpenAI 格式的原生 Tool Calling(Function Calling)。

    OCR 的工作机制是通过 OpenAI 兼容 API 的 tools 参数向模型发送工具定义(如 code_comment、task_done 等),并期望模型在响应的 tool_calls 结构化字段中返回工具调用。但像 qwen2.5-coder:14b、deepseek-r1:14b/32b 这类模型,虽然 Ollama 提供了 OpenAI 兼容的 API 端点,Tool Calling 能力取决于底层模型本身是否经过 Function Calling 微调。这些模型在收到工具定义后,通常会把工具调用以纯文本形式输出在 content 字段中,而不是放在 API 响应的 tool_calls 字段里,导致 OCR 无法解析,从而不断重试。

    解决建议

    建议更换为支持原生 Tool Calling 的模型。以下是一些通过 Ollama 可用且支持原生 Tool Calling 的推荐模型:

    模型 尺寸 说明
    qwen3:32b 20GB Qwen3 系列,原生支持 Tool Calling
    qwen3:14b 9.4GB 适合显存有限的环境
    qwen3:8b 5.2GB 轻量级,适合入门
    MFDoom/deepseek-r1-tool-calling:32b 19GB 专门针对 Tool Calling 微调的 DeepSeek R1
    安装示例:

    ollama pull qwen3:32b
    然后重新配置 OCR:

    ocr config provider

    选择 custom,设置模型为 qwen3:32b

    注意:deepseek-r1 原版是纯推理模型,没有经过 Function Calling 微调,所以天然不支持 Tool Calling。qwen2.5-coder 的 Tool Calling 支持也不够稳定。建议优先选择 Qwen3 系列模型。

    如果更换模型后仍然遇到问题,请告知我们,我们会进一步排查。

    已经更换了也补充了相关信息,这个有进一步消息吗?

  6. lizhengfeng101 commented on Jun 29, 2026

    @lizhengfeng101
    Contributor

    你好,感谢持续跟进!

    为了进一步定位问题,请在终端运行以下 最小化测试命令,直接验证你的模型是否支持原生 Tool Calling:

    curl http://127.0.0.1:11434/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
      "model": "qwen3:32b",
      "messages": [
        {"role": "user", "content": "The code below has a bug, use the code_comment tool to report it.\n\nfunc add(a, b int) int {\n  return a - b\n}"}
      ],
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "task_done",
            "description": "Call when the review is complete.",
            "parameters": {
              "type": "object",
              "properties": {
                "state": {"type": "string", "enum": ["DONE","FAILED"]}
              },
              "required": ["state"]
            }
          }
        },
        {
          "type": "function",
          "function": {
            "name": "code_comment",
            "description": "Report a code issue found during review.",
            "parameters": {
              "type": "object",
              "properties": {
                "comments": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "content": {"type": "string"},
                      "existing_code": {"type": "string"},
                      "suggestion_code": {"type": "string"}
                    },
                    "required": ["content","existing_code"]
                  }
                }
              },
              "required": ["comments"]
            }
          }
        }
      ]
    }'

    如果你用的是 MFDoom/deepseek-r1-tool-calling:32b,把 "model" 字段改成对应名称即可。

    如何判断结果

    ✅ 模型支持 Tool Calling

    响应 JSON 中应该有 tool_calls 字段,类似:

    {
      "choices": [{
        "message": {
          "tool_calls": [{
            "function": {
              "name": "code_comment",
              "arguments": "{\"comments\":[{\"content\":\"...\",\"existing_code\":\"...\"}]}"
            }
          }]
        }
      }]
    }

    ❌ 模型不支持 Tool Calling

    响应中 没有 tool_calls 字段,工具调用被当成纯文本写在了 content 里。这就是 OCR 反复重试的原因。

    ⏱️ 超时问题

    请同时关注这个请求的耗时。OCR 默认单次请求超时为 5 分钟,而 32b 模型在 M1 Pro 32GB 上可能推理较慢。如果上面的简单请求就要好几分钟,建议:

    • 换用更小的模型:qwen3:14b(9.4GB)或 qwen3:8b(5.2GB)
    • 或者在 OCR 配置中增大超时(后续版本我们会考虑提供配置项)

    请把完整的 curl 输出贴回来,这样我们就能明确判断是 Tool Calling 兼容性问题还是超时问题,从而给出针对性的解决方案。

  7. semi-xi commented on Jun 29, 2026

    @semi-xi
    Author

    你好,感谢持续跟进!

    为了进一步定位问题,请在终端运行以下 最小化测试命令,直接验证你的模型是否支持原生 Tool Calling:

    curl http://127.0.0.1:11434/v1/chat/completions
    -H "Content-Type: application/json"
    -d '{
    "model": "qwen3:32b",
    "messages": [
    {"role": "user", "content": "The code below has a bug, use the code_comment tool to report it.\n\nfunc add(a, b int) int {\n return a - b\n}"}
    ],
    "tools": [
    {
    "type": "function",
    "function": {
    "name": "task_done",
    "description": "Call when the review is complete.",
    "parameters": {
    "type": "object",
    "properties": {
    "state": {"type": "string", "enum": ["DONE","FAILED"]}
    },
    "required": ["state"]
    }
    }
    },
    {
    "type": "function",
    "function": {
    "name": "code_comment",
    "description": "Report a code issue found during review.",
    "parameters": {
    "type": "object",
    "properties": {
    "comments": {
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "content": {"type": "string"},
    "existing_code": {"type": "string"},
    "suggestion_code": {"type": "string"}
    },
    "required": ["content","existing_code"]
    }
    }
    },
    "required": ["comments"]
    }
    }
    }
    ]
    }'
    如果你用的是 MFDoom/deepseek-r1-tool-calling:32b,把 "model" 字段改成对应名称即可。

    如何判断结果

    ✅ 模型支持 Tool Calling

    响应 JSON 中应该有 tool_calls 字段,类似:

    {
    "choices": [{
    "message": {
    "tool_calls": [{
    "function": {
    "name": "code_comment",
    "arguments": "{"comments":[{"content":"...","existing_code":"..."}]}"
    }
    }]
    }
    }]
    }

    ❌ 模型不支持 Tool Calling

    响应中 没有 tool_calls 字段,工具调用被当成纯文本写在了 content 里。这就是 OCR 反复重试的原因。

    ⏱️ 超时问题

    请同时关注这个请求的耗时。OCR 默认单次请求超时为 5 分钟,而 32b 模型在 M1 Pro 32GB 上可能推理较慢。如果上面的简单请求就要好几分钟,建议:

    • 换用更小的模型:qwen3:14b(9.4GB)或 qwen3:8b(5.2GB)
    • 或者在 OCR 配置中增大超时(后续版本我们会考虑提供配置项)

    请把完整的 curl 输出贴回来,这样我们就能明确判断是 Tool Calling 兼容性问题还是超时问题,从而给出针对性的解决方案。

    针对超时的问题,目前在结果中有以下信息,这个就是超时了吗?

    main_task
    Request #1
    300000ms
    context deadline exceeded
    

    此外在没有超时的接口里面,返回了这些内容,这个是符合预期的吗?

    main_task
    Request #1
    qwen3:32b
    P:3643 C:706
    208396ms
    Request #2
    qwen3:32b
    P:3661 C:489
    168952ms
    Tool Calls (1)
    ⚙
    code_comment
    Arguments
    {"comments":[{"content":"Potential missing null check when accessing coverAreaMap from CreateContext. If context value is undefined during initial render or unexpected load state, this could cause runtime errors when accessing nested properties in senderAllowCountry.","existing_code":"+  const { coverAreaMap } = useContainer(CreateContext);\n+  const allowCountry = senderAllowCountry(coverAreaMap);","suggestion":"Consider adding a null check or default value pattern:\nconst { coverAreaMap = {} } = useContainer(CreateContext);\n... or use optional chaining:\nconst allowCountry = senderAllowCountry(coverAreaMap ?? {});"}]}
    Result
    (async)
    

    qwen 32b的结果

    {
      "id": "chatcmpl-556",
      "object": "chat.completion",
      "created": 1782704078,
      "model": "qwen3:32b",
      "system_fingerprint": "fp_ollama",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "",
            "reasoning": "Okay, let's see. The user provided a Go function called add, which takes two integers a and b and returns their sum. But wait, looking at the code, the return statement is a - b. Oh, that's a bug! The function is supposed to add them, but it's subtracting instead. So the correct operation should be a + b. I need to report this using the code_comment tool.\n\nFirst, I'll note the existing code line: return a - b. The suggestion is to change it to return a + b. The content of the comment should explain that the function name is add, so the operation should be addition. I'll structure the tool call with these details. Make sure all required fields are included: content, existing_code. The suggestion_code is optional but helpful here. Let me put that together in JSON as specified.\n",
            "tool_calls": [
              {
                "id": "call_thjj23y0",
                "index": 0,
                "type": "function",
                "function": {
                  "name": "code_comment",
                  "arguments": "{\"comments\":[{\"content\":\"The function is named 'add' but performs subtraction. Change the operation to addition.\",\"existing_code\":\"return a - b\",\"suggestion_code\":\"return a + b\"}]}"
                }
              }
            ]
          },
          "finish_reason": "tool_calls"
        }
      ],
      "usage": {
        "prompt_tokens": 247,
        "completion_tokens": 241,
        "total_tokens": 488
      }
    }

    MFDoom/deepseek-r1-tool-calling:32b 测试结果

    {
      "id": "chatcmpl-172",
      "object": "chat.completion",
      "created": 1782704367,
      "model": "MFDoom/deepseek-r1-tool-calling:32b",
      "system_fingerprint": "fp_ollama",
      "choices": [
        {
          "index": 0,
          "message": {
            "role": "assistant",
            "content": "\n\nTo report this bug correctly using `code_comment`, we'll note that the function `add` incorrectly performs subtraction instead of addition.\n\n**Step-by-step explanation:**\n\n1. **Function Purpose:** The function is named `add`, indicating it should return the sum of two integers `a` and `b`.\n2. **Current Implementation:** Inside the function, it returns `a - b`, which is a subtraction operation, not an addition.\n3. **Impact:** This causes incorrect results when the function is used to expect an addition. For example, `add(5, 3)` would return `2` instead of `8`.\n4. **Suggested Fix:** Change `return a - b` to `return a + b`.\n\nHere's how you could use `code_comment` to report this:\n\n```plaintext\n// BUG: Function 'add' incorrectly calculates the sum using subtraction. It should return a + b.\n```",
            "reasoning": "\nOkay, I've got this problem where the user provided a piece of Go code with a function called add. The function is supposed to take two integers and return their sum. But when I look at the code, instead of adding them, it's subtracting b from a. That's definitely not right.\n\nSo, the first thing I think about is what the function is named: add. It suggests that its purpose is addition. However, looking at the implementation, it returns a - b. So clearly, there's a mistake here because subtraction isn't addition. The user wants this code to perform an addition operation correctly.\n\nI need to figure out how to fix this bug. Well, instead of subtracting, we should add the two numbers. So, changing the return statement from 'a - b' to 'a + b' would solve the problem. That seems straightforward enough.\n\nNow, considering best practices for reporting bugs, I should point out both what's wrong and how to fix it. It's helpful to explain why the current code isn't doing what it's supposed to do. In this case, using subtraction makes the function return a different operation than intended. \n\nAdditionally, maybe adding some context or examples can make the explanation clearer for someone who's new to this. For example, if I give an instance where a is 5 and b is 3, the current function returns 2 instead of the expected 8. That concrete example can help others understand why the change is necessary.\n\nSo, putting it all together, my report needs to clearly state that there's a bug in the add function due to subtraction instead of addition and offer the corrected code as a solution.\n"
          },
          "finish_reason": "stop"
        }
      ],
      "usage": {
        "prompt_tokens": 35,
        "completion_tokens": 535,
        "total_tokens": 570
      }
    }

    就结果来说的话MFDoom/deepseek-r1-tool-calling:32b 这个是没有tool的。我重新改用14b测试下.

  8. lizhengfeng101 commented on Jun 29, 2026

    @lizhengfeng101
    Contributor

    @semi-xi 感谢反馈,你贴图的那个日志表明确实是 LLM 请求超时了,可以跟进 #238,这位开发者正在修复。

  9. chethanuk commented on Jul 17, 2026

    @chethanuk
    Contributor

    Opened #400 with the docs for both root causes discussed here (FAQ tool-calling entry + curl verification snippet ×3 locales, plus configuration.md Ollama example and Timeouts section), and a small DocsPage.tsx fix so CJK in-page anchors actually navigate. Before/after screenshots of all six affected views are in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions