Skip to content

fix: switch to Ollama OpenAI-compatible endpoint to resolve tool call validation errors#4

Open
SusieGlitter wants to merge 2 commits intoOpenDataBox:mainfrom
SusieGlitter:ollama
Open

fix: switch to Ollama OpenAI-compatible endpoint to resolve tool call validation errors#4
SusieGlitter wants to merge 2 commits intoOpenDataBox:mainfrom
SusieGlitter:ollama

Conversation

@SusieGlitter
Copy link
Copy Markdown

  1. Related Issue
    Closes Ollama integration fails with tool calls: "role" field missing in Message validation #2

  2. Reproduction Process & Results
    I access ollama-0.21.0 on linux server with SSH Port Forwarding while running opencook windows PC, so I can use ollama as model provider with localhost:11434

using opencook_config.yaml with config:

...
...

model_providers:
    ollama:
        base_url: http://localhost:11434/v1
        api_key: ollama
        provider: ollama

models:
    plan_agent_model:
        model_provider: ollama
        model: qwen3.5:cloud

...
...

running opencook in powershell:

python -m code_agent interactive --config-file opencook_config.yaml --working-dir "G:\db\opencook\sqlite-src-3530000"

and result is after entering the command, ollama serve show that no request is sent and no step is shown in opencook cli

  1. Changes
    Refactored ollama_client.py: Switched from the native Ollama library/endpoint to the OpenAI-compatible /v1/chat/completions endpoint.

Improved Message Formatting: By using the OpenAI protocol, messages (including tool roles and tool_outputs) are now automatically formatted correctly according to standard schemas.

  1. Final Performance & Verification
    doing the same in 2. Reproduction Process & Results, and opencook runs as expected
image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama integration fails with tool calls: "role" field missing in Message validation

1 participant