[GH-ISSUE #9055] Question: Structured Inputs for Tools? #5894

Closed
opened 2026-04-12 17:13:50 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @sheffler on GitHub (Feb 12, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/9055

Originally assigned to: @ParthSareen on GitHub.

I am exploring the use of MCP tools with Ollama. The Tool syntax for Ollama tools allows the definition of the input parameters of a tool as simple types (int, string, etc) or even an array. However, it seems that the current syntax does now allow the ability to describe the schema of the items of an array.

In JsonSchema syntax, a property that is an array will have a "type" of "array" and an associated "items" field that gives the type of the elements of the array.

I have modified an Ollama client to send a Tool definition that includes an "items" field. What I am observing is that the "items" field is stripped off when received by Ollama and logged.

Question: Should there be a facility to describe the types of the items of an array?

See below the "tools" definition (in PYthon syntax) that I sent to Ollama, and the excerpt from the Ollama logs where the "items" fields are not present. Does it make sense to extend the type definition to include more features from JSON schema? Is there an alternate way to more completely describe an array of objects?

tools = [
{
  'type': 'function',
  'function': {
    'name': 'preparation_tool',
    'description': "Prepare the samples for analyze.  Mark samples as 'passed' or 'failed'. ",
    'parameters': {
      'type': 'object',
      'required': ['sample_list'],
      'properties': {
        'sample_list': {
	  'type': 'array',
	  'items': {
	    'properties': {
	      'sample_name': {
	         'description': 'sample name identifier',
		 'title': 'Sample Name', 'type': 'string'
	       },
	       'mass': {
	         'description': 'sample mass in ng',
		 'title': 'Mass', 'type': 'integer'
		}
	      },
	      'required': ['sample_name', 'mass'],
	      'title': 'InputSample',
	      'type': 'object'
	    }
	  }
	}
      }
    }
   },


and from the "server.log"


"type\":\"function\",\"function\":{\"name\":\"preparation_tool\",\"description\":\"Prepare the samples for analyze.  Mark samples as 'passed' or 'failed'. \",\"parameters\":{\"type\":\"object\",\"required\":[\"sample_list\"],\"properties\":{\"sample_list\":{\"type\":\"array\",\"description\":\"\"}}}}}\n{\"type\":\"function\",\"function\":{\"name\":\"analyzer_tool\",\"description\":\"Analyze the samples that have been prepared\",\"parameters\":{\"type\":\"object\",\"required\":[\"preparation_list\"],\"properties\":{\"preparation_list\":{\"type\":\"array\",\"description\":\"\"}}}}}\n\ncan you describe the format of the arguments my preparation_tool requires?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"

Originally created by @sheffler on GitHub (Feb 12, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/9055 Originally assigned to: @ParthSareen on GitHub. I am exploring the use of MCP tools with Ollama. The Tool syntax for Ollama tools allows the definition of the input parameters of a tool as simple types (int, string, etc) or even an array. However, it seems that the current syntax does now allow the ability to describe the schema of the items of an array. In JsonSchema syntax, a property that is an array will have a "type" of "array" and an associated "items" field that gives the type of the elements of the array. I have modified an Ollama client to send a Tool definition that includes an "items" field. What I am observing is that the "items" field is stripped off when received by Ollama and logged. Question: Should there be a facility to describe the types of the items of an array? See below the "tools" definition (in PYthon syntax) that I sent to Ollama, and the excerpt from the Ollama logs where the "items" fields are not present. Does it make sense to extend the type definition to include more features from JSON schema? Is there an alternate way to more completely describe an array of objects? ``` tools = [ { 'type': 'function', 'function': { 'name': 'preparation_tool', 'description': "Prepare the samples for analyze. Mark samples as 'passed' or 'failed'. ", 'parameters': { 'type': 'object', 'required': ['sample_list'], 'properties': { 'sample_list': { 'type': 'array', 'items': { 'properties': { 'sample_name': { 'description': 'sample name identifier', 'title': 'Sample Name', 'type': 'string' }, 'mass': { 'description': 'sample mass in ng', 'title': 'Mass', 'type': 'integer' } }, 'required': ['sample_name', 'mass'], 'title': 'InputSample', 'type': 'object' } } } } } }, ``` and from the "server.log" ``` "type\":\"function\",\"function\":{\"name\":\"preparation_tool\",\"description\":\"Prepare the samples for analyze. Mark samples as 'passed' or 'failed'. \",\"parameters\":{\"type\":\"object\",\"required\":[\"sample_list\"],\"properties\":{\"sample_list\":{\"type\":\"array\",\"description\":\"\"}}}}}\n{\"type\":\"function\",\"function\":{\"name\":\"analyzer_tool\",\"description\":\"Analyze the samples that have been prepared\",\"parameters\":{\"type\":\"object\",\"required\":[\"preparation_list\"],\"properties\":{\"preparation_list\":{\"type\":\"array\",\"description\":\"\"}}}}}\n\ncan you describe the format of the arguments my preparation_tool requires?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" ```
GiteaMirror added the feature request label 2026-04-12 17:13:50 -05:00
Author
Owner

@sheffler commented on GitHub (Apr 2, 2025):

See https://github.com/ollama/ollama/pull/10091 which addresses this issue.

<!-- gh-comment-id:2773180297 --> @sheffler commented on GitHub (Apr 2, 2025): See https://github.com/ollama/ollama/pull/10091 which addresses this issue.
Author
Owner

@ParthSareen commented on GitHub (Apr 2, 2025):

Thanks @sheffler will check it out!

<!-- gh-comment-id:2773288875 --> @ParthSareen commented on GitHub (Apr 2, 2025): Thanks @sheffler will check it out!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5894