Execute a Run
Sends input to the Agentic app within a specific session and retrieves the response. This endpoint supports multiple execution modes - synchronous, asynchronous, and streaming.Path Parameters
Request Parameters
sessionIdentity- Required An array of objects, each with a type and value, used to identify or create sessions and manage user session mappings. The three supported identifier types are:- sessionIdentity(highest priority)
- sessionReference
- userReference(lowest priority)
input- Required An array of user inputs to the Agentic application. This field can be used to pass the user query or the tool details when a tool is invoked directly. When passing the user input, provide the following fields.
- type: Set this to “text”.
- content: the actual user input string
- type: Set this to “tool_input”.
- content: Use this object to pass the tool parameters.
debug- Optional Controls debug info in the response, useful for troubleshooting, understanding agent behavior, and inspecting intermediate reasoning or function execution. The debug objects contain the following fields:
- Enable - set this to true to enable debug information in the response.
-
debugMode - this can take the following values:
- function-call - Includes details about the function(s) triggered by the agent
- thoughts - Provides internal reasoning traces of the agent.
- all - Includes both function-call and thoughts
- Currently, only thoughts are supported.*
stream- Optional Enable or disable streaming of the agent’s response. This object contains two fields:
- enable - set it to true to enable message streaming.
- streamMode - set the streaming type. It can take the following values:
- tokens: The response is sent token by token as the agent generates it.
- messages: Each complete thought or output message is sent as a separate event as soon as it’s available.
- custom: Allows for custom streaming behavior
isAsync- Optional Indicates whether the API should execute asynchronously.
- false (default): Executes synchronously and returns the result immediately.
- true: Executes asynchronously. If the callbackURL is provided, the response is shared on the URL else this API returns a
runIdthat can be used to retrieve the status or result later.
callbackUrl- Optional The endpoint to which the asynchronous response should be sent. Must be a valid, publicly accessible URL.
- If provided, the Platform makes an HTTP POST request to the
callbackURLwith the result payload after the processing is complete. - If omitted in an async request, you must use the
runIdto fetch the result manually.
callbackToken- Optional An authentication token included when sending the asynchronous response to the specified
callbackUrl. This ensures secure delivery of results to the given endpoint.
If callbackToken is provided, it’s included in the HTTP request headers to the callbackURL using the standard Bearer token authentication format:
attachments- Optional Allows users to associate files with the session. This object takes the following fields:
- enable (String): Set to “true” to attach files to the session
- includeFiles (Array): List of file IDs to include
as contextual information in the session. - excludeFiles (Array): List of file IDs to exclude from the session.
metadata- Optional Allows users to pass metadata information. This data is stored in sessionMeta and remains available for the duration of the session.
invoke- Optional This field allows direct invocation of a specific agent or tool within the application, bypassing the orchestrator. It is particularly useful when the client knows exactly which agent or tool should handle the request. The invoke field accepts an array of task objects. Each task object must include:
- type:
- Set this to “agent” to specify the task as an agent invocation.
- Set this to “tool” for invoking a specific tool.
- name: The name of the agent or tool you want to invoke.
agent, provide the following additional fields.
- toolType: This field is used only for tools. It can take one of the following values -
workflow,codeormcp. - agentName : Name of the agent with which the tool is associated.
input field.
The first agent/tool in the tasks array is used for handling the query. If more than one agent/tool is given in this array, the first one is used, and the others are ignored.
source- Optional Identifies the system from which the API request is initiated. This field enables better analytics, monitoring, and observability by indicating what triggered the agentic app execution. This field is available as a filter in the session logs. If not provided, the Platform automatically assigns the default value. Recommended Values:
- AP: This is the default value. Used when the
sourcefield is not explicitly passed. - AIS-AA: AI for Service - Agent Assist
- AIS-QM: AI for Service - Quality Module
- AIS-CC: AI for Service - Contact Center
- AP-PG: Agent Platform - Playground
- AP-ES: Agent Platform - Evaluation Studio
- AIW: AI for Work
- AIP: AI for Process
- MP: Agent Platform - Marketplace
Sample Request
Response
Returns the agent’s response to the query along with the session details.Sample Response
Sample Response when OAuth authorization is pending
Note: If any tool used by an agent requires OAuth authorization, the API response for the initial request (when a new session starts) will include a special event of typeIDP_Redirect. This event contains a URL that the user must visit to complete the authorization. If the required authorization is not completed, the associated tools will return an error upon invocation.
Specific Config Samples
Synchronous Execution
- Waits for the agent to respond. Best for real-time interactions.
-
Key configuration:
Asynchronous Execution
-
Key configuration fields:
- “isAsync”: true
- callbackUrl(optional): The endpoint to which the response must be sent.
- callbackToken(optional): Auth token to be passed for authentication on the callbackUrl.
- Initiates an agent run.
-
If
callbackUrlis provided, the response is sent to that endpoint upon completion. The Platform makes an HTTP POST request to thecallbackURLwith the result payload. -
If
callbackUrlis not provided, the API responds immediately with arunID, which can be used later to query the execution status and response. -
If
callbackTokenis provided, it is included in the HTTP request headers to thecallbackURLusing the standard Bearer token authentication format:Authorization: Bearer <callbackToken>
Streaming Execution
- Enables streaming of response from the agent. Returns tokens or messages as the agent responds.
- Key Configuration fields:
stream.enable: Set to “true” to enable streamingstream.streamMode:- “messages” - Sends complete messages as they’re generated
- “tokens” - Streams final results as tokens.
- “custom” - For customized streaming behavior
Thought Streaming
Thought Streaming allows the agent to return the intermediate reasoning steps (called “thoughts”) while it’s working and not just the final answer. This helps with transparency and debugging. Thought Streaming can be enabled with the help of debug and streaming config fields. Key Configurations:
Example - Thoughts enabled, streaming disabled.
Different reasoning thoughts are part of an array, debug, in the response. Thoughts can be identified by the type fields of the object as shown below.
Adding Attachments to a session
You can attach a file to a session and use it in the current execution. This is a two-step process:- Upload the file. Use the File Upload API to upload the desired files. Uploaded files remain available only for the duration of the session.
- Include the File in Execution Add the file details while invoking the execute API in the attachments field. You can use the include and exclude arrays to specify the list of files to be added to the current run of the execute API.
- Files are not automatically included in the current execution after upload. They must be explicitly listed in the includeFiles array.
- The isActive field in the response indicates whether a file was used in the current run:
- true → File was included in the execution.
- false → File was excluded.
- Once a file is added to the includeFiles list, it remains associated with the session for its duration unless it is explicitly removed by listing it in excludeFiles.
Invoking an Agent
- Use the invoke field to specify the agent to be invoked.
Invoking a Tool
- Use the invoke field to specify that it is for invoking a tool.
- Use the inputs field to specify the parameters of the tool.
- The tool has read/write access to session-scoped memory.
Points to Notes
- When implementing thought streaming, ensure proper error handling for cases where the connection might be interrupted.
- The source field in debug thoughts indicates the origin of each thought (for example, agent, orchestrator), helping pinpoint issues during debugging and trace execution flow across components.
- When using streamMode: “tokens”, be aware that only the final output content will be streamed token by token, while debug thoughts will still come as complete messages.
- The sessionInfo object contains important tracking information, including the status of the conversation and run identifiers.
- For high-frequency thought streams, implement client-side buffering to ensure a smooth user experience and reduce rendering or processing lag.
Find Run Status
Returns the status and response of a run. It is useful for asynchronous runs.Path Parameters
Request Parameters
Sample Request
Response
Returns the current status and details of the run. The important fields include:- run.status: Describes the current status of the run. It can have the following values:
- success - The run completed successfully without any errors.
- failed - The run encountered an error and did not complete successfully.
- Pending - The run has been created but has not started yet.
- Running - The run is currently in progress.
- run.kwargs.output: Contains the final result after a successful run.
Sample Response
Check the output only if the status is ‘success’. The output field may contain error details if the status field is otherwise. If status is “pending” or “running”, poll again after a suitable delay.