Problem using agentic search

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): OpenSearch 3.4

Describe the issue:

I’ve followed all the steps to configure agentic search on my local OpenSearch server to use a local LLM running under Ollama. However, my query produces the error below.

ChatGPT suggests that this is a bug with the information below. It suggests that I implement a proxy to convert the float that is causing the problem to an integer. This seems like a long way to go to address this issue.

Can anyone shed any additional light on this problem? Should I open an issue on this?

Note: It would be great of this forum included an additional category for AI-related plugins.

This is a type-compatibility bug at the OpenSearch ↔ Ollama boundary

  • OpenSearch’s agent framework is emitting tool-call objects where tool_calls[*].index is serialized as 0.0 (a floating-point JSON number).

  • Ollama’s OpenAI-compatible handler defines ToolCall.Index as an integer and uses Go JSON unmarshalling, which rejects 0.0 for an int.

OpenSearch documentation/examples show this “.0 numeric” pattern ("index": 0.0) in agent outputs, which strongly suggests OpenSearch is using a floating numeric type internally (e.g., Double) and round-tripping it back into subsequent requests.

What’s happening in your run

Agentic execution is multi-step:

  1. Model returns tool calls

  2. OpenSearch executes tools

  3. OpenSearch calls the model again, including prior assistant messages with tool_calls
    It’s step (3) where OpenSearch sends index: 0.0 back to Ollama, and Ollama fails.

Configuration:

OS/Hardware: MacOS: MacBook Pro M3 Max
OpenSearch: OpenSearch 3.4 running under Docker
LLM: A Qwen model running under Ollama. Ollama is running on host

Relevant Logs or Screenshots:
This is the query I issued using curl (sorry for the formatting):

curl -k -u admin:admin -X GET “``http://localhost:9200/able_chunks_v1/_search?search_pipeline=agentic-pipeline``” -H “Content-Type: application/json” -d ‘{
“query”: {
“agentic”: {
“query_text”: “How many documents are there in the index”
}
}
}’

And this is the error:
”json: cannot unmarshal number 0.0 into Go struct field ToolCall.messages.tool_calls.index of type int”

Full error:
{“error”:{“root_cause”:[{“type”:“illegal_argument_exception”,“reason”:“Agentic search failed - Agent execution error - Agent ID: [_Nh7rZsBMCptIK-aGFFT], Error: [Error from remote service: {"error":{"message":"json: cannot unmarshal number 0.0 into Go struct field ToolCall.messages.tool_calls.index of type int","type":"invalid_request_error","param":null,"code":null}}]”}],“type”:“illegal_argument_exception”,“reason”:“Agentic search failed - Agent execution error - Agent ID: [_Nh7rZsBMCptIK-aGFFT], Error: [Error from remote service: {"error":{"message":"json: cannot unmarshal number 0.0 into Go struct field ToolCall.messages.tool_calls.index of type int","type":"invalid_request_error","param":null,"code":null}}]”,“caused_by”:{“type”:“status_exception”,“reason”:“Error from remote service: {"error":{"message":"json: cannot unmarshal number 0.0 into Go struct field ToolCall.messages.tool_calls.index of type int","type":"invalid_request_error","param":null,"code":null}}”}},“status”:400

Hi Brian,

we also noticed this issue when using gson to convert to string format, it would convert integer to float format. There is a merged fix in place: Add JSON validation in StringUtils fromJson/toJson by jiapingzeng · Pull Request #4520 · opensearch-project/ml-commons · GitHub . Since you are using local opensearch server, would you try building the ml-common plugin into jar file up to this commit? and then replace at your local cluster ml-common plugin jar file. As long as the version is the same, you should be able to replace the plugin file easily.

Try out this commit and see if this can resolve your issue. If not, feel free to raise an issue in ml-common repo GitHub - opensearch-project/ml-commons: ml-commons provides a set of common machine learning algorithms, e.g. k-means, or linear regression, to help developers build ML related features within OpenSearch.

Thanks mingshi. I actually took the path of least resistance on this switched from Ollama to LM Studio which works fine. I’ll try to test the patch you mentioned at some point, but at this point, this is no longer a high priority for me.

Thanks again for your update.

Brian Levine

1 Like

Was able to reproduce this issue on 3.4, verified that the serialization error no longer occurs with #4520 :slight_smile: