> ## Documentation Index
> Fetch the complete documentation index at: https://cognitio-agent.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Type Alias: AgentMessage

> Generated from the public TypeScript API.

```ts theme={null}
type AgentMessage =
  | {
  compactionId?: string;
  preCompactTokenCount?: number;
  preservedMessageIds?: string[];
  raw?: unknown;
  subtype: "system.compact_boundary";
  summaryText?: string;
  trigger?: "auto" | "manual";
  type: "system";
}
  | {
  compactionId?: never;
  preCompactTokenCount?: never;
  preservedMessageIds?: never;
  raw?: unknown;
  subtype: string;
  summaryText?: never;
  trigger?: never;
  type: "system";
}
  | {
  message: CognitioMessage;
  parts?: CognitioPart[];
  raw?: unknown;
  type: "user";
}
  | {
  message: CognitioMessage;
  parts?: CognitioPart[];
  raw?: unknown;
  reasoning?: string;
  text?: string;
  type: "assistant";
}
  | {
  delta: string;
  field: string;
  messageId: string;
  partId: string;
  raw?: unknown;
  type: "partial";
}
  | {
  part: CognitioPart;
  raw?: unknown;
  type: "part";
}
  | {
  raw?: unknown;
  sessionId: string;
  todos: TodoItem[];
  type: "todo.updated";
}
  | {
  checkpoint: CheckpointHandle;
  raw?: unknown;
  type: "checkpoint.created";
}
  | {
  affectedFiles: string[];
  checkpointId: string;
  raw?: unknown;
  type: "session.rewound";
}
  | {
  input: unknown;
  raw?: unknown;
  requestId: string;
  tool: string;
  type: "permission.request";
}
  | {
  input: unknown;
  name: string;
  raw?: unknown;
  toolUseId: string;
  type: "tool.use";
}
  | {
  output: unknown;
  raw?: unknown;
  toolUseId: string;
  type: "tool.result";
}
  | {
  agent: string;
  childSessionId: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  taskId: string;
  toolCallId?: string;
  type: "subagent.start";
}
  | {
  agent: string;
  childSessionId: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  status: string;
  taskId: string;
  title?: string;
  toolCallId?: string;
  type: "subagent.progress";
}
  | {
  agent: string;
  childSessionId: string;
  error?: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  result?: string;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  status: "completed" | "error" | "cancelled";
  taskId: string;
  toolCallId?: string;
  type: "subagent.stop";
}
  | RateLimitEvent
  | TaskStartedEvent
  | TaskProgressEvent
  | TaskNotificationEvent
  | TaskStoppedEvent
  | {
  raw?: unknown;
  result: ResultMessage;
  text?: string;
  type: "result";
}
  | {
  event: CognitioEvent;
  type: "raw";
};
```

Normalized stream messages surfaced by `session.stream()`. Original runtime
event payloads are available in `raw` where applicable.

## Union Members

### Type Literal

```ts theme={null}
{
  compactionId?: string;
  preCompactTokenCount?: number;
  preservedMessageIds?: string[];
  raw?: unknown;
  subtype: "system.compact_boundary";
  summaryText?: string;
  trigger?: "auto" | "manual";
  type: "system";
}
```

***

### Type Literal

```ts theme={null}
{
  compactionId?: never;
  preCompactTokenCount?: never;
  preservedMessageIds?: never;
  raw?: unknown;
  subtype: string;
  summaryText?: never;
  trigger?: never;
  type: "system";
}
```

***

### Type Literal

```ts theme={null}
{
  message: CognitioMessage;
  parts?: CognitioPart[];
  raw?: unknown;
  type: "user";
}
```

***

### Type Literal

```ts theme={null}
{
  message: CognitioMessage;
  parts?: CognitioPart[];
  raw?: unknown;
  reasoning?: string;
  text?: string;
  type: "assistant";
}
```

***

### Type Literal

```ts theme={null}
{
  delta: string;
  field: string;
  messageId: string;
  partId: string;
  raw?: unknown;
  type: "partial";
}
```

***

### Type Literal

```ts theme={null}
{
  part: CognitioPart;
  raw?: unknown;
  type: "part";
}
```

***

### Type Literal

```ts theme={null}
{
  raw?: unknown;
  sessionId: string;
  todos: TodoItem[];
  type: "todo.updated";
}
```

***

### Type Literal

```ts theme={null}
{
  checkpoint: CheckpointHandle;
  raw?: unknown;
  type: "checkpoint.created";
}
```

***

### Type Literal

```ts theme={null}
{
  affectedFiles: string[];
  checkpointId: string;
  raw?: unknown;
  type: "session.rewound";
}
```

***

### Type Literal

```ts theme={null}
{
  input: unknown;
  raw?: unknown;
  requestId: string;
  tool: string;
  type: "permission.request";
}
```

***

### Type Literal

```ts theme={null}
{
  input: unknown;
  name: string;
  raw?: unknown;
  toolUseId: string;
  type: "tool.use";
}
```

***

### Type Literal

```ts theme={null}
{
  output: unknown;
  raw?: unknown;
  toolUseId: string;
  type: "tool.result";
}
```

***

### Type Literal

```ts theme={null}
{
  agent: string;
  childSessionId: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  taskId: string;
  toolCallId?: string;
  type: "subagent.start";
}
```

***

### Type Literal

```ts theme={null}
{
  agent: string;
  childSessionId: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  status: string;
  taskId: string;
  title?: string;
  toolCallId?: string;
  type: "subagent.progress";
}
```

***

### Type Literal

```ts theme={null}
{
  agent: string;
  childSessionId: string;
  error?: string;
  messageId: string;
  parentSessionId: string;
  raw?: unknown;
  result?: string;
  rootSessionId: string;
  spawnMode: "fresh" | "inherit";
  status: "completed" | "error" | "cancelled";
  taskId: string;
  toolCallId?: string;
  type: "subagent.stop";
}
```

***

[`RateLimitEvent`](../interfaces/RateLimitEvent)

***

[`TaskStartedEvent`](../interfaces/TaskStartedEvent)

***

[`TaskProgressEvent`](../interfaces/TaskProgressEvent)

***

[`TaskNotificationEvent`](../interfaces/TaskNotificationEvent)

***

[`TaskStoppedEvent`](../interfaces/TaskStoppedEvent)

***

### Type Literal

```ts theme={null}
{
  raw?: unknown;
  result: ResultMessage;
  text?: string;
  type: "result";
}
```

Terminal message of a turn. `text` mirrors `result.text` so a consumer
that only switches on the envelope never has to reach into `result`.

***

### Type Literal

```ts theme={null}
{
  event: CognitioEvent;
  type: "raw";
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.