Skip to content

Conversation

jmorganca
Copy link
Member

@jmorganca jmorganca commented Jul 23, 2025

This PR loosens tool call parsing in two ways:

  1. Allows for arguments ahead of function names
  2. No longer checks required fields, leaving it up to the caller

It tightens parsing in one way: tool calls without arguments such as {"name": "say_hello"} will no longer be parsed. This should be a non use case

Fixes #11505

@jmorganca jmorganca requested a review from ParthSareen July 23, 2025 20:56
@jmorganca jmorganca changed the title tools: support arguments before tools, loosten argument requirements tools: loosen tool calling argument parsing Jul 23, 2025
@jmorganca jmorganca changed the title tools: loosen tool calling argument parsing tools: loosen tool argument parsing Jul 23, 2025
Comment on lines +246 to +251
if args, ok := obj["arguments"].(map[string]any); ok {
return args, true
}
if args, ok := obj["parameters"].(map[string]any); ok {
return args, true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of remember that nested examples broke with something like this last time I wrote it. Maybe double check models like cohere still work

Copy link
Member

@ParthSareen ParthSareen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved w/ double checking models

@jmorganca
Copy link
Member Author

Checked with:

  • qwen3
  • llama3.1
  • devstral
  • command-r7b
  • granite3.3:8b

With some heavier tool use tests

@jmorganca jmorganca merged commit 4f8a016 into main Jul 24, 2025
15 of 16 checks passed
@jmorganca jmorganca deleted the jmorganca/tool-fixes branch July 24, 2025 04:21
@gabe-l-hart
Copy link
Contributor

I was just about to request this feature (support for "arguments" before "name"). Thanks for reading my mind!

gabe-l-hart added a commit to gabe-l-hart/ollama that referenced this pull request Jul 25, 2025
* origin/main:
cli: catch upstream errors gracefully (ollama#11512)
tools: loosen tool argument parsing (ollama#11509)
server: use slices.Equal to simplify code (ollama#11502)
s#x/exp/maps#maps# (ollama#11506)
Fix GetModelInfo (ollama#11496)
Update linux.md (ollama#11462)
rick-github pushed a commit to rick-github/ollama that referenced this pull request Aug 20, 2025
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.

tool call parsing broken when arguments precede function name
3 participants