Search

POST /api/exec/search is the search box as an API call: it returns the agents that match a query, best first, and leaves the running to the caller.

The request

query is the user's text. tag is optional: omit it to use the tag in the Search settings, send an empty string to search every tag, or name a tag to search only that tag.

$ curl -s -X POST http://127.0.0.1:9020/api/exec/search \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -d '{"query": "how many vacation days do I have left"}'
{"success": true,
 "searchResults": [{"agentName": "hr_policy", "agentTitle": "HR policies and entitlements"}],
 "searchBehavior": "executeTopMatch", "followupBehavior": "executeTopMatch"}

The response

searchResults holds zero, one, two or three agents; see How matching works for when each happens. An empty list means nothing matched, and the client should say so rather than run anything. searchBehavior and followupBehavior are the account's settings. A client uses them to behave like the GUI: run the top match at once, run only a lone match, or show the list and let the user choose.

Running the match

Search does not run anything. Take the chosen agentName and call execAgent with the same query under inputs.query. For a follow-up, send the query to search again and pass the conversation's convid to execAgent, whichever agent matched.