[PR #12738] [MERGED] tools: parse tool calls that don't conform to ("name": name, "arguments": args} #39807

Closed
opened 2026-04-23 00:48:14 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12738
Author: @rick-github
Created: 10/22/2025
Status: Merged
Merged: 10/22/2025
Merged by: @jmorganca

Base: mainHead: tool-cool-parse


📝 Commits (3)

  • 709631d tools: parse tools calls that don't conform to ("name": name, "arguments": args}
  • 8dec155 simplify function declaration
  • b55f500 gofumpt-ify

📊 Changes

2 files changed (+34 additions, -12 deletions)

View changed files

📝 tools/tools.go (+14 -11)
📝 tools/tools_test.go (+20 -1)

📄 Description

Some models (eg Apertus) are trained to return a simpler tool call format. Instead of

{"name": name-of-tool, "arguments": {"arg1", arg1}}

they return

{"name-of-tool": {"arg1": arg1}}

Currently the parsing in the tool call parser correctly detects the name, but then takes the entire object as the argument parameter, rather than just the argument list, so the tool_call is:

{"name":"name-of-tool","arguments':{"name-of-tool":{"arg1":arg1}}}

This PR handles the case where no "name" parameter is found, but there is key of the tool name that has a map as a value.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/12738 **Author:** [@rick-github](https://github.com/rick-github) **Created:** 10/22/2025 **Status:** ✅ Merged **Merged:** 10/22/2025 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `tool-cool-parse` --- ### 📝 Commits (3) - [`709631d`](https://github.com/ollama/ollama/commit/709631d934b87daf66c6529f30b7540433577df4) tools: parse tools calls that don't conform to ("name": name, "arguments": args} - [`8dec155`](https://github.com/ollama/ollama/commit/8dec1557f03cd3c46f9e07f06dd42d9ca6d26bed) simplify function declaration - [`b55f500`](https://github.com/ollama/ollama/commit/b55f50057f024e6913508a862614950ab9e14f90) gofumpt-ify ### 📊 Changes **2 files changed** (+34 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `tools/tools.go` (+14 -11) 📝 `tools/tools_test.go` (+20 -1) </details> ### 📄 Description Some models (eg Apertus) are trained to return a simpler tool call format. Instead of ``` {"name": name-of-tool, "arguments": {"arg1", arg1}} ``` they return ``` {"name-of-tool": {"arg1": arg1}} ``` Currently the parsing in the tool call parser correctly detects the name, but then takes the entire object as the argument parameter, rather than just the argument list, so the `tool_call` is: ``` {"name":"name-of-tool","arguments':{"name-of-tool":{"arg1":arg1}}} ``` This PR handles the case where no "name" parameter is found, but there is key of the tool name that has a map as a value. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 00:48:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#39807