API Reference
AgentEventBody
type AgentEventBody =
| {
sessionId: string;
system?: string;
tools?: ToolSpec[];
type: AgentStart;
}
| {
step: number;
type: TurnStart;
}
| {
text: string;
type: ReasoningDelta;
}
| {
text: string;
type: TextDelta;
}
| {
message: Message;
type: Message;
}
| {
message: Message;
origin: InjectedMessageOrigin;
type: MessageInjected;
}
| {
args: ToolArguments;
toolCallId: string;
toolName: string;
type: ToolStart;
}
| {
isError: boolean;
result: string;
toolCallId: string;
toolName: string;
type: ToolEnd;
}
| {
messages: Message[];
steps: number;
type: AgentEnd;
};Defined in: types/events.ts:70
The payload of an event, minus the timestamp.
Union Members
Type Literal
{
sessionId: string;
system?: string;
tools?: ToolSpec[];
type: AgentStart;
}| Name | Type | Description | Defined in |
|---|---|---|---|
sessionId | string | The session whose run is starting. | types/events.ts:75 |
system? | string | [observability] The run's system prompt, if any. Carried on this event so an observer (a tracer, a UI) sees it without having to tap the model request — the loop already knows it at start. | types/events.ts:81 |
tools? | ToolSpec[] | [observability] The full tool specs available to the model this run — same rationale as system: surfaced once up front so observers needn't reconstruct the tool surface from later events. | types/events.ts:87 |
type | AgentStart | Discriminant; see AgentEventType.AgentStart. | types/events.ts:73 |
Type Literal
{
step: number;
type: TurnStart;
}| Name | Type | Description | Defined in |
|---|---|---|---|
step | number | 1-based index of the model turn that is starting. | types/events.ts:93 |
type | TurnStart | Discriminant; see AgentEventType.TurnStart. | types/events.ts:91 |
Type Literal
{
text: string;
type: ReasoningDelta;
}| Name | Type | Description | Defined in |
|---|---|---|---|
text | string | A chunk of the assistant's reasoning channel. | types/events.ts:99 |
type | ReasoningDelta | Discriminant; see AgentEventType.ReasoningDelta. | types/events.ts:97 |
Type Literal
{
text: string;
type: TextDelta;
}| Name | Type | Description | Defined in |
|---|---|---|---|
text | string | A chunk of the assistant's text content. | types/events.ts:105 |
type | TextDelta | Discriminant; see AgentEventType.TextDelta. | types/events.ts:103 |
Type Literal
{
message: Message;
type: Message;
}| Name | Type | Description | Defined in |
|---|---|---|---|
message | Message | The complete message that was appended to the conversation. | types/events.ts:111 |
type | Message | Discriminant; see AgentEventType.Message. | types/events.ts:109 |
Type Literal
{
message: Message;
origin: InjectedMessageOrigin;
type: MessageInjected;
}| Name | Type | Description | Defined in |
|---|---|---|---|
message | Message | The caller-supplied message injected into the live run. | types/events.ts:117 |
origin | InjectedMessageOrigin | Which queue it was drained from — steering or follow-up. | types/events.ts:119 |
type | MessageInjected | Discriminant; see AgentEventType.MessageInjected. | types/events.ts:115 |
Type Literal
{
args: ToolArguments;
toolCallId: string;
toolName: string;
type: ToolStart;
}| Name | Type | Description | Defined in |
|---|---|---|---|
args | ToolArguments | The parsed arguments the tool will receive. | types/events.ts:129 |
toolCallId | string | Id of the tool call about to run, matching its AgentEventType.ToolEnd event. | types/events.ts:125 |
toolName | string | Name of the tool about to run. | types/events.ts:127 |
type | ToolStart | Discriminant; see AgentEventType.ToolStart. | types/events.ts:123 |
Type Literal
{
isError: boolean;
result: string;
toolCallId: string;
toolName: string;
type: ToolEnd;
}| Name | Type | Description | Defined in |
|---|---|---|---|
isError | boolean | Whether the tool reported an error. | types/events.ts:141 |
result | string | The tool result text folded back into the conversation. | types/events.ts:139 |
toolCallId | string | Id of the finished tool call, matching its AgentEventType.ToolStart event. | types/events.ts:135 |
toolName | string | Name of the tool that ran. | types/events.ts:137 |
type | ToolEnd | Discriminant; see AgentEventType.ToolEnd. | types/events.ts:133 |
Type Literal
{
messages: Message[];
steps: number;
type: AgentEnd;
}| Name | Type | Description | Defined in |
|---|---|---|---|
messages | Message[] | The full conversation as of run end. | types/events.ts:147 |
steps | number | Total number of model turns the run took. | types/events.ts:149 |
type | AgentEnd | Discriminant; see AgentEventType.AgentEnd. | types/events.ts:145 |
Remarks
The loop's call sites construct these; emit stamps each one centrally on the
way out (see AgentEvent), so no call site has to remember to set the
time.