Running agents

POST /api/exec/execAgent runs a named agent. The call returns when the agent finishes, or streams the run as it happens.

The request

FieldMeaning
agentNameThe agent to run.
inputsA JSON object. The agent reads it as sys.inputs. The value under query is what the agent reads as sys.query; the search box sends the user's text there.
convidOmit to start a new conversation. Send the id from an earlier response to continue that conversation.
streamfalse (the default) returns one response when the agent finishes. true streams the run; see Streaming.
$ curl -s -X POST http://127.0.0.1:9020/api/exec/execAgent \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -d '{"agentName": "morning_briefing", "inputs": {"query": "what changed overnight", "team": "payments"}}'

The response

FieldMeaning
resultCodeHow the run ended; the values are listed below.
convidThe conversation. Send it back to continue.
agentNameThe agent that ran.
outputThe agent's output as a list of parts: text (Markdown), html, or image with a mimeType. Present only when the call did not stream.
askInputPresent when the agent paused on ask: a message and the list of inputs to collect. See below.

Result codes

ValueMeaning
successAgent completed successfully (Not included in error report)
askAgent ended in a ask command (Not included in error report)
callFailedCall to an external system failed
failCommandAgent ended with a fail command
errorInAgentAgent has some coding error
unknownConversationConversation is unknown or expired, or it is paused on an ask by a different agent
timedOutAgent timed out, based on the max agent runtime setting
stoppedUser cancelled the agent execution
mustLoginSession timed out in the middle of an agent execution
unexpectedAn unknown exception was raised in the agent

success and ask are the two normal endings. Every other code is recorded in the error report. unknownConversation is what a client receives when the conversation is unknown or has expired, or when it is paused on an ask recorded by a different agent.

Answering an ask

When resultCode is ask, the agent has paused. askInput.inputs lists the inputs. Each input has a name, a type, a label, a description, the options and a default; the types are str, password, text, chooseOne and chooseMany. Collect the answers. Then call execAgent again with the same agentName and convid, and the answers as inputs, keyed by input name. The agent resumes at the ask command. The pause survives any delay: the answers may arrive the next day, from another client.

$ curl -s -X POST http://127.0.0.1:9020/api/exec/execAgent \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -d '{"agentName": "travel_booking", "convid": "'$CONVID'", "inputs": {"departure": "Boston", "seat": "aisle"}}'

Continuing a conversation

A call with a convid restores the conversation's state before the agent runs, so agent and conversation variables and prompt history are available. The agent named in the call need not be the agent that ran before; a conversation can move from one agent to another, as it does after a follow-up search. A conversation expires after its last use, 7 days on the Free plan and 90 days on Paid, unless the user pinned it.

Validating a draft

POST /api/dev/validateDraftStream runs a developer's draft against its validation query, with tracing on. The request names the draftid; the response adds validationSuccess, compileErrors and runtimeError to the fields above. The GUI's validation view is this call with stream: true.