Handle Agent RPC by ID
Handle JSON-RPC requests for an agent by its unique ID.
ParametersExpand Collapse
body: AgentRpcParams { method, params, id, jsonrpc }
params: CreateTaskRequest { name, params, task_metadata } | CancelTaskRequest { task_id, task_name } | InterruptTaskRequest { task_id, task_name } | 2 more
The parameters for the agent RPC request
CreateTaskRequest { name, params, task_metadata }
name?: string | null
Optional human-readable name for the task. When set it must be globally unique. task/create is get-or-create by name: reusing an existing name returns the existing task (with its prior history) instead of creating a new one, so omit name (or make it unique, e.g. by appending a UUID) whenever each call should produce a fresh task.
SendMessageRequest { content, stream, task_id, 2 more }
The message that was sent to the agent
SendEventRequest { content, task_id, task_name }
The content to send to the event
ReturnsExpand Collapse
AgentRpcResponse { result, id, error, jsonrpc }
The result of the agent RPC request
Array<TaskMessage { content, task_id, id, 3 more } >
The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
StreamTaskMessageStart { content, index, parent_task_message, type }
Event for starting a streaming message
Represents a message in the agent system.
This entity is used to store messages in MongoDB, with each message associated with a specific task.
The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
StreamTaskMessageDelta { delta, index, parent_task_message, type }
Event for streaming chunks of content
Represents a message in the agent system.
This entity is used to store messages in MongoDB, with each message associated with a specific task.
The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
StreamTaskMessageFull { content, index, parent_task_message, type }
Event for streaming the full content
Represents a message in the agent system.
This entity is used to store messages in MongoDB, with each message associated with a specific task.
The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
StreamTaskMessageDone { index, parent_task_message, type }
Event for indicating the task is done
Represents a message in the agent system.
This entity is used to store messages in MongoDB, with each message associated with a specific task.
The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
Task { id, cleaned_at, created_at, 6 more }
Event { id, agent_id, sequence_id, 3 more }
The content of the event
Handle Agent RPC by ID
import Agentex from 'agentex';
const client = new Agentex({
apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});
const agentRpcResponse = await client.agents.rpc('agent_id', {
method: 'event/send',
params: {},
});
console.log(agentRpcResponse.id);{
"result": [
{
"content": {
"author": "user",
"content": "content",
"attachments": [
{
"file_id": "file_id",
"name": "name",
"size": 0,
"type": "type"
}
],
"format": "markdown",
"style": "static",
"type": "text"
},
"task_id": "task_id",
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"streaming_status": "IN_PROGRESS",
"updated_at": "2019-12-27T18:11:19.117Z"
}
],
"id": 0,
"error": {},
"jsonrpc": "2.0"
}Returns Examples
{
"result": [
{
"content": {
"author": "user",
"content": "content",
"attachments": [
{
"file_id": "file_id",
"name": "name",
"size": 0,
"type": "type"
}
],
"format": "markdown",
"style": "static",
"type": "text"
},
"task_id": "task_id",
"id": "id",
"created_at": "2019-12-27T18:11:19.117Z",
"streaming_status": "IN_PROGRESS",
"updated_at": "2019-12-27T18:11:19.117Z"
}
],
"id": 0,
"error": {},
"jsonrpc": "2.0"
}