ollama - 💡(How to fix) Fix tool_call.arguments truncated to exactly 214 chars on Ollama Cloud API [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#15647Fetched 2026-04-18 05:52:00
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

Across 35+ error instances, every single invalid arguments field is exactly 214 characters long, strongly suggesting a server-side buffer or limit: should return an error rather than silently truncating.

RAW_BUFFERClick to expand / collapse

Bug Description
When using models via the Ollama Cloud API (https://ollama.com/v1), tool_call.function.arguments is truncated to exactly 214 characters. This produces invalid JSON that causes HTTP 400: invalid tool call
arguments on subsequent API calls that include the truncated arguments in conversation history.

Steps to Reproduce

  1. Call POST /v1/chat/completions with glm-5.1 (or qwen3.5) and tool definitions
  2. In a multi-turn conversation where the model generates tool calls with arguments > 214 chars 3. The returned tool_call.function.arguments is truncated to exactly 214 characters 4. Sending the conversation history (including the truncated args) back to the API returns 400: invalid tool call arguments
    Evidence
    Across 35+ error instances, every single invalid arguments field is exactly 214 characters long, strongly suggesting a server-side buffer or limit:

All 46 invalid tool_calls: 214 chars (100%)

Examples of truncated arguments:

  • {"code":"from hermes_tools import terminal\n\nrepos = [\n
    ("alexpate/awesome-design-systems"... → truncated mid-string - {"command":"cd ~/design-md && for d in */; do echo "${d%/}"; done | sort > /tmp/... → truncated mid-command - {"path":"/home/emma/北雅英语/BEIYA-DESIGN-WORKFLOW.md","content":"# 北雅 AI 设计... → truncated mid-content Expected Behavior tool_call.function.arguments should contain complete, valid JSON regardless of length. If there is a length limit, the model should be constrained to produce arguments within that limit, or the API
    should return an error rather than silently truncating.

Environment

  • Ollama Cloud API (https://ollama.com/v1) - Models: glm-5.1, qwen3.5:397b, glm-5.1:cloud (via local Ollama)
  • Plan: Pro

extent analysis

TL;DR

The issue can be mitigated by handling the truncation of tool_call.function.arguments to 214 characters, potentially by modifying the client-side code to handle or prevent such truncation.

Guidance

  • Verify the exact length of tool_call.function.arguments in the API response to confirm the 214-character limit.
  • Consider modifying the client-side code to handle truncated arguments, potentially by checking the length of tool_call.function.arguments and handling or removing truncated values.
  • Investigate if there are any API configuration options or parameters that can increase the character limit for tool_call.function.arguments.
  • Review the model's behavior to determine if it can be constrained to produce arguments within the 214-character limit.

Example

No explicit code example can be provided without more context, but a potential approach could involve checking the length of tool_call.function.arguments before sending it in subsequent API calls:

if len(tool_call.function.arguments) > 214:
    # Handle or remove truncated value
    pass

Notes

The root cause of the issue appears to be a server-side buffer or limit, but without further information, it is unclear if this can be modified or configured. The suggested mitigations focus on handling the truncation on the client-side.

Recommendation

Apply a workaround to handle the truncation of tool_call.function.arguments, as it is unclear if the server-side limit can be modified. This approach allows for continued use of the API while minimizing the impact of the truncation issue.

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…

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 tool_call.arguments truncated to exactly 214 chars on Ollama Cloud API [1 participants]