ollama - 💡(How to fix) Fix Gemini 3 tool continuation via /api/chat and /v1/chat/completions is missing thought_signature [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#15109Fetched 2026-04-08 01:41:20
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
closed ×1

Root Cause

gemini-3-flash-preview:cloud can emit tool calls, but multi-turn tool continuation fails because the follow-up request needs a Gemini thought_signature that Ollama does not expose through its public chat APIs.

Code Example

ollama --version
# ollama version is 0.15.6

---

curl -sS http://127.0.0.1:11434/api/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "stream":false,
    "think":true,
    "messages":[
      {"role":"user","content":"Call the session_status tool with an empty JSON object, then stop."}
    ],
    "tools":[
      {
        "type":"function",
        "function":{
          "name":"session_status",
          "description":"Show the current session state",
          "parameters":{"type":"object","properties":{},"additionalProperties":false}
        }
      }
    ]
  }'

---

{
  "message": {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "id": "chj80b12",
        "function": {
          "index": 0,
          "name": "session_status",
          "arguments": {}
        }
      }
    ]
  },
  "done": true
}

---

curl -sS http://127.0.0.1:11434/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "messages":[
      {"role":"user","content":"Call the session_status tool with an empty JSON object, then stop."}
    ],
    "tools":[
      {
        "type":"function",
        "function":{
          "name":"session_status",
          "description":"Show the current session state",
          "parameters":{"type":"object","properties":{},"additionalProperties":false}
        }
      }
    ]
  }'

---

Function call is missing a thought_signature in functionCall parts.
RAW_BUFFERClick to expand / collapse

What is the issue?

gemini-3-flash-preview:cloud can emit tool calls, but multi-turn tool continuation fails because the follow-up request needs a Gemini thought_signature that Ollama does not expose through its public chat APIs.

This makes agent loops fail on the second step:

  1. model emits a tool call
  2. client executes the tool
  3. client sends tool result back with prior assistant turn
  4. Gemini rejects the continuation because the prior function call parts are missing thought_signature

Ollama version

ollama --version
# ollama version is 0.15.6

Reproduction

First request to /api/chat:

curl -sS http://127.0.0.1:11434/api/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "stream":false,
    "think":true,
    "messages":[
      {"role":"user","content":"Call the session_status tool with an empty JSON object, then stop."}
    ],
    "tools":[
      {
        "type":"function",
        "function":{
          "name":"session_status",
          "description":"Show the current session state",
          "parameters":{"type":"object","properties":{},"additionalProperties":false}
        }
      }
    ]
  }'

Response:

{
  "message": {
    "role": "assistant",
    "content": "",
    "tool_calls": [
      {
        "id": "chj80b12",
        "function": {
          "index": 0,
          "name": "session_status",
          "arguments": {}
        }
      }
    ]
  },
  "done": true
}

No thought_signature is present in:

  • message
  • tool_calls[*]
  • tool_calls[*].function

Streaming /api/chat also does not expose it.

/v1/chat/completions has the same problem:

curl -sS http://127.0.0.1:11434/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "messages":[
      {"role":"user","content":"Call the session_status tool with an empty JSON object, then stop."}
    ],
    "tools":[
      {
        "type":"function",
        "function":{
          "name":"session_status",
          "description":"Show the current session state",
          "parameters":{"type":"object","properties":{},"additionalProperties":false}
        }
      }
    ]
  }'

Response contains normal tool_calls, but still no Gemini signature metadata.

Failure on continuation

When the tool result is sent back in the next turn, Gemini returns:

Function call is missing a thought_signature in functionCall parts.

Why this looks like an Ollama API gap

Current public message types do not seem to have any field for Gemini tool-call signatures.

Relevant source:

  • api/types.go: Message includes thinking, tool_calls, tool_name, tool_call_id, but no thought_signature
  • docs/capabilities/tool-calling.mdx: multi-turn examples say to replay thinking + content + tool_calls
  • x/cmd/run.go: agent loop persists assistant turns with Content, Thinking, and ToolCalls, but no signature field

I also searched the current source tree and could not find:

  • thought_signature
  • thinkingSignature

Expected behavior

For Gemini models that require tool-call continuation signatures, Ollama should expose the necessary signature metadata through:

  • /api/chat
  • /v1/chat/completions

so clients can replay the assistant tool-call turn correctly on the next request.

Actual behavior

Ollama emits the initial tool call, but does not expose the signature needed for the next turn, so multi-turn tool calling breaks for Gemini.

extent analysis

Fix Plan

To fix the issue, we need to modify the Ollama API to expose the thought_signature metadata for Gemini models. Here are the steps:

  • Modify the Message struct in api/types.go to include a thought_signature field.
  • Update the /api/chat and /v1/chat/completions endpoints to include the thought_signature in the response.
  • Modify the agent loop in x/cmd/run.go to persist the thought_signature along with the assistant turn.

Example code changes:

// api/types.go
type Message struct {
    // ...
    ThoughtSignature string `json:"thought_signature,omitempty"`
    // ...
}

// api/chat.go
func (h *ChatHandler) HandleChat(w http.ResponseWriter, r *http.Request) {
    // ...
    message := &Message{
        // ...
        ThoughtSignature: thoughtSignature, // retrieve the thought signature from the Gemini model
        // ...
    }
    // ...
}

// x/cmd/run.go
func (a *Agent) persistAssistantTurn(turn *AssistantTurn) {
    // ...
    turn.ThoughtSignature = thoughtSignature // persist the thought signature
    // ...
}

Verification

To verify the fix, send a request to /api/chat or /v1/chat/completions with a Gemini model and a tool call, and check that the response includes the thought_signature metadata. Then, send a follow-up request with the tool result and the replayed assistant turn, and check that the Gemini model accepts the continuation.

Example verification code:

curl -sS http://127.0.0.1:11434/api/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "stream":false,
    "think":true,
    "messages":[
      {"role":"user","content":"Call the session_status tool with an empty JSON object, then stop."}
    ],
    "tools":[
      {
        "type":"function",
        "function":{
          "name":"session_status",
          "description":"Show the current session state",
          "parameters":{"type":"object","properties":{},"additionalProperties":false}
        }
      }
    ]
  }'

# Check that the response includes the thought_signature metadata
# ...

# Send a follow-up request with the tool result and the replayed assistant turn
curl -sS http://127.0.0.1:11434/api/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "model":"gemini-3-flash-preview:cloud",
    "stream":false,
    "think":true,
    "messages":[
      {"role":"assistant","content":"","thought_signature":"<thought_signature>","tool_calls":[{"id":"<tool

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

For Gemini models that require tool-call continuation signatures, Ollama should expose the necessary signature metadata through:

  • /api/chat
  • /v1/chat/completions

so clients can replay the assistant tool-call turn correctly on the next request.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix Gemini 3 tool continuation via /api/chat and /v1/chat/completions is missing thought_signature [1 participants]