[GH-ISSUE #5990] Tools and properties.type Not Supporting Arrays #3747

Closed
opened 2026-04-12 14:33:25 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @xonlly on GitHub (Jul 26, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/5990

Originally assigned to: @ParthSareen on GitHub.

What is the issue?

Title: Issue with DynamicStructuredTool and properties.type Not Supporting Arrays in LangchainJS

Description:

I am encountering an issue when using DynamicStructuredTool in LangchainJS. Specifically, the type property within properties does not currently support arrays. This results in an error when I try to use a nullable argument specified as ["string", "null"]. The error message is as follows:

LLM run errored with error: "HTTP error! status: 400 Response: 
{\"error\":{\"message\":\"json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null}}\n
\nMistralAPIError: HTTP error! status: 400 Response: 
{\"error\":{\"message\":\"json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null}}\n
 at MistralClient._request (file:///Users/xonlly/projects/devana.ai/serveur/node_modules/@mistralai/mistralai/src/client.js:162:17)\n
 at processTicksAndRejections (node:internal/process/task_queues:95:5)\n
 at MistralClient.chat (file:///Users/xonlly/projects/devana.ai/serveur/node_modules/@mistralai/mistralai/src/client.js:338:22)\n
 at /Users/xonlly/projects/devana.ai/serveur/node_modules/@langchain/mistralai/dist/chat_models.cjs:366:27\n
 at RetryOperation._fn (/Users/xonlly/projects/devana.ai/serveur/node_modules/p-retry/index.js:50:12)"

JSON Configuration:

{
  "model": "mistral-nemo",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "search-files",
        "description": "Search all files in the collection",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {
              "type": ["string", "null"]
            }
          },
          "required": ["query"],
          "additionalProperties": false,
          "$schema": "http://json-schema.org/draft-07/schema#"
        }
      }
    }
  ],
  "temperature": 0.7,
  "top_p": 1,
  "stream": false,
  "tool_choice": "required"
}

Steps to Reproduce:

  1. Use LangchainJS with DynamicStructuredTool.
  2. Define a nullable argument with ["string", "null"] in the type property.
  3. Observe the error upon execution.

Expected Behavior:

The type property should accept arrays to support nullable arguments without causing an error.

Actual Behavior:

An error occurs because the type property does not support arrays, resulting in a failure to unmarshal the array into a Go struct field.

Proposed Solution:

Update the type property within properties to support arrays, allowing for nullable arguments to be correctly processed.

Environment:

  • Ollama version: 0.3.0
  • Operating System: Ubuntu 22.04

Additional Context:

Any guidance or updates to address this limitation would be greatly appreciated. Thank you!

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

0.3.0

Originally created by @xonlly on GitHub (Jul 26, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/5990 Originally assigned to: @ParthSareen on GitHub. ### What is the issue? **Title:** Issue with `DynamicStructuredTool` and `properties.type` Not Supporting Arrays in LangchainJS **Description:** I am encountering an issue when using `DynamicStructuredTool` in LangchainJS. Specifically, the `type` property within `properties` does not currently support arrays. This results in an error when I try to use a nullable argument specified as `["string", "null"]`. The error message is as follows: ``` LLM run errored with error: "HTTP error! status: 400 Response: {\"error\":{\"message\":\"json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null}}\n \nMistralAPIError: HTTP error! status: 400 Response: {\"error\":{\"message\":\"json: cannot unmarshal array into Go struct field .tools.function.parameters.properties.type of type string\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null}}\n at MistralClient._request (file:///Users/xonlly/projects/devana.ai/serveur/node_modules/@mistralai/mistralai/src/client.js:162:17)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at MistralClient.chat (file:///Users/xonlly/projects/devana.ai/serveur/node_modules/@mistralai/mistralai/src/client.js:338:22)\n at /Users/xonlly/projects/devana.ai/serveur/node_modules/@langchain/mistralai/dist/chat_models.cjs:366:27\n at RetryOperation._fn (/Users/xonlly/projects/devana.ai/serveur/node_modules/p-retry/index.js:50:12)" ``` **JSON Configuration:** ```json { "model": "mistral-nemo", "messages": [ { "role": "user", "content": "Hello" } ], "tools": [ { "type": "function", "function": { "name": "search-files", "description": "Search all files in the collection", "parameters": { "type": "object", "properties": { "query": { "type": ["string", "null"] } }, "required": ["query"], "additionalProperties": false, "$schema": "http://json-schema.org/draft-07/schema#" } } } ], "temperature": 0.7, "top_p": 1, "stream": false, "tool_choice": "required" } ``` **Steps to Reproduce:** 1. Use LangchainJS with `DynamicStructuredTool`. 2. Define a nullable argument with `["string", "null"]` in the `type` property. 3. Observe the error upon execution. **Expected Behavior:** The `type` property should accept arrays to support nullable arguments without causing an error. **Actual Behavior:** An error occurs because the `type` property does not support arrays, resulting in a failure to unmarshal the array into a Go struct field. **Proposed Solution:** Update the `type` property within `properties` to support arrays, allowing for nullable arguments to be correctly processed. **Environment:** - Ollama version: 0.3.0 - Operating System: Ubuntu 22.04 **Additional Context:** Any guidance or updates to address this limitation would be greatly appreciated. Thank you! ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version 0.3.0
GiteaMirror added the bug label 2026-04-12 14:33:25 -05:00
Author
Owner

@vavjeeva commented on GitHub (Aug 16, 2024):

I am also getting the same error when i use semantic kernel with TextMemoryPlugin. Is this issue fixed?

<!-- gh-comment-id:2293552013 --> @vavjeeva commented on GitHub (Aug 16, 2024): I am also getting the same error when i use semantic kernel with TextMemoryPlugin. Is this issue fixed?
Author
Owner

@ruckerzerg commented on GitHub (Oct 18, 2024):

Can confirm this issue...

<!-- gh-comment-id:2422612921 --> @ruckerzerg commented on GitHub (Oct 18, 2024): Can confirm this issue...
Author
Owner

@rozgo commented on GitHub (Mar 1, 2025):

We ran into this issue and should be fixed with: https://github.com/ollama/ollama/pull/9434

<!-- gh-comment-id:2691892847 --> @rozgo commented on GitHub (Mar 1, 2025): We ran into this issue and should be fixed with: https://github.com/ollama/ollama/pull/9434
Author
Owner

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

Will be out in next release!

<!-- gh-comment-id:2784791256 --> @ParthSareen commented on GitHub (Apr 7, 2025): Will be out in next release!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#3747