Skip to content

SearchIndexTool frequently failed  #4351

@mingshl

Description

@mingshl

when testing failed in conversational agents, observed in logging,
indexMappingTool frequently failed, which wasted llm call and token usage.

Exception message:

"{""role"":""assistant"",""content"":null,""tool_calls"":[{""id"":""call_j9ALOKavukeMN1M0odPNyUDd"",""type"":""function"",""function"":{""name"":""SearchIndexTool"",""arguments"":""{\""index\"":\""opensearch-release\"",\""query\"":\""{\\\""query\\\"":{\\\""match_all\\\"":{}}}\""}""}}],""refusal"":null,""annotations"":[]}"
"{""role"":""tool"",""tool_call_id"":""call_j9ALOKavukeMN1M0odPNyUDd"",""content"":""Tool SearchIndexTool failed: Expected [START_OBJECT] but found [VALUE_STRING]""}"```

Expected correct function calling

[{""id"":""call_2u4yS00o05eQ5Ay6UDDWaD4x"",""type"":""function"",""function"":{""name"":""SearchIndexTool"",""arguments"":""{\""index\"":\""opensearch-release\"",\""query\"":{\""query\"":{\""match_all\"":

then it will return search result properly

"{""role"":""tool"",""content"":""{\""_index\"":\""opensearch-release\"",\""_source\"":{\""release_note\"":\""{\\\""next_page\\\"":\\\""[https://duckduckgo.com/html?q\\\\u003dOpenSearch+releases+after+version+2.0\\\\u0026s\\\\u003d10\\\\u0026nextParams\\\\u003d\\\\u0026v\\\\u003dl\\\\u0026o\\\\u003djson\\\\u0026dc\\\\u003d11\\\\u0026api\\\\u003dd.js\\\\u0026vqd\\\\u003d4-302390017373502469848272537024929795231\\\\u0026kl\\\\u003dwt-wt\\\\\\](https://duckduckgo.com/html?q%5C%5C%5C%5Cu003dOpenSearch+releases+after+version+2.0%5C%5C%5C%5Cu0026s%5C%5C%5C%5Cu003d10%5C%5C%5C%5Cu0026nextParams%5C%5C%5C%5Cu003d%5C%5C%5C%5Cu0026v%5C%5C%5C%5Cu003dl%5C%5C%5C%5Cu0026o%5C%5C%5C%5Cu003djson%5C%5C%5C%5Cu0026dc%5C%5C%5C%5Cu003d11%5C%5C%5C%5Cu0026api%5C%5C%5C%5Cu003dd.js%5C%5C%5C%5Cu0026vqd%5C%5C%5C%5Cu003d4-302390017373502469848272537024929795231%5C%5C%5C%5Cu0026kl%5C%5C%5C%5Cu003dwt-wt%5C%5C%5C%5C%5C%5C)"",\\\""items\\\"":[{\\\""url\\\"":\\\""[https://opensearch.org/releases/\\\\\\](https://opensearch.org/releases/%5C%5C%5C%5C%5C%5C)"",\\\""title\\\"":\\\""\\\"",\\\""content\\\"":\\\""Skip to main content Search Close Search search Menu About Foundation Governing Board Charter Meeting Calendar Platform Platform OpenSearch CoreOpenSearch is a powerful search and analytics engine built on Apache Lucene. OpenSearch DashboardsOur data visualization toolset is a flexible, fully integrated solution for visually exploring and querying your data. OpenSearch Data PrepperA server-side data collector designed to enrich, transform, and aggregate data for downstream analytics with Opensearch. OpenSearch Vector EnginePower machine learning and generative AI applications with a high-performance database designed for the way AI understands data. Capabilities Machine learning and AI Vector Search Anomaly Detection Search E-Commerce Document Search Search Relevance Observability Performance …..

The exception is due to the SearchIndexTool is expected a proper escape query json string, most LLM tends to not able to write proper escape at the first time, and it might try second or third time to write the proper the query string in json format.

There are two ways to fix this,

  1. in the "query " parameters on the searchIndexTool, check on the format and try to parse it properly when it's malformed by llm to prevent the exception from happening, this save one llm call
  2. change the "query" parameters format to be an easy understanding format, for example, json format instead of json string.

feel free to propose more solutions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions