Skip to content

Conversation

@timstoop
Copy link

Summary

Adds an optional timeout parameter to the search and esql tools, allowing LLMs to specify query timeouts using Elasticsearch time units (e.g., "30s", "2m", "1m30s").

Motivation

Queries can run indefinitely without timeout controls, which can cause:

  • Resource exhaustion on Elasticsearch clusters
  • Poor user experience with hanging requests
  • Difficulty managing long-running queries

Changes

  • Added optional timeout parameter to SearchParams with default value of "120s"
  • Added optional timeout parameter to EsqlQueryParams with default value of "120s"
  • For search: uses .timeout() method on the Elasticsearch search API
  • For esql: uses query_timeout in the ES|QL request body
  • Includes code formatting changes from cargo fmt

Testing

  • ✅ All existing tests pass
  • cargo clippy passes with no warnings
  • ✅ Code formatted with cargo fmt
  • ✅ Docker image builds successfully

Example Usage

{
  "name": "search",
  "arguments": {
    "index": "my-index",
    "query_body": {"query": {"match_all": {}}},
    "timeout": "30s"
  }
}

The timeout parameter accepts Elasticsearch time unit format and defaults to 120 seconds if not specified.

Add optional timeout parameter to search and esql tools, allowing LLMs
to specify query timeouts (e.g., "30s", "2m"). Defaults to 120s to
prevent long-running queries.

- Add timeout parameter to SearchParams and EsqlQueryParams
- Implement timeout via Elasticsearch API parameters
- Include auto-formatting changes from cargo fmt

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
37c02a6

Please, read and sign the above mentioned agreement if you want to contribute to this project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant