Search for an agent

Introduced 2.13

Use this command to search for agents you’ve already created. You can provide any OpenSearch search query in the request body.

Path and HTTP methods

  1. GET /_plugins/_ml/agents/_search
  2. POST /_plugins/_ml/agents/_search

Example request: Searching for all agents

  1. POST /_plugins/_ml/agents/_search
  2. {
  3. "query": {
  4. "match_all": {}
  5. },
  6. "size": 1000
  7. }

copy

Example request: Searching for agents of a certain type

  1. POST /_plugins/_ml/agents/_search
  2. {
  3. "query": {
  4. "term": {
  5. "type": {
  6. "value": "flow"
  7. }
  8. }
  9. }
  10. }

copy

Example: Searching for an agent by description

  1. GET _plugins/_ml/agents/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "should": [
  6. {
  7. "match": {
  8. "description": "test agent"
  9. }
  10. }
  11. ]
  12. }
  13. },
  14. "size": 1000
  15. }

copy

Example response

  1. {
  2. "took": 2,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 6,
  13. "relation": "eq"
  14. },
  15. "max_score": 0.15019803,
  16. "hits": [
  17. {
  18. "_index": ".plugins-ml-agent",
  19. "_id": "8HXlkI0BfUsSoeNTP_0P",
  20. "_version": 1,
  21. "_seq_no": 17,
  22. "_primary_term": 2,
  23. "_score": 0.13904166,
  24. "_source": {
  25. "created_time": 1707532959502,
  26. "last_updated_time": 1707532959502,
  27. "name": "Test_Agent_For_RagTool",
  28. "description": "this is a test flow agent",
  29. "type": "flow",
  30. "tools": [
  31. {
  32. "description": "A description of the tool",
  33. "include_output_in_agent_response": false,
  34. "type": "RAGTool",
  35. "parameters": {
  36. "inference_model_id": "gnDIbI0BfUsSoeNT_jAw",
  37. "embedding_model_id": "Yg7HZo0B9ggZeh2gYjtu_2",
  38. "input": "${parameters.question}",
  39. "source_field": """["text"]""",
  40. "embedding_field": "embedding",
  41. "index": "my_test_data",
  42. "query_type": "neural",
  43. "prompt": """
  44. Human:You are a professional data analyst. You will always answer question based on the given context first. If the answer is not directly shown in the context, you will analyze the data and find the answer. If you don't know the answer, just say don't know.
  45. Context:
  46. ${parameters.output_field}
  47. Human:${parameters.question}
  48. Assistant:"""
  49. }
  50. }
  51. ]
  52. }
  53. }
  54. ]
  55. }
  56. }

Response body fields

For response field descriptions, see Register Agent API request fields.