# Stream console logs for a hosted agent session

`GET /agents/{agent_name}/versions/{agent_version}/sessions/{session_id}:logstream`

Streams console logs (stdout / stderr) for a specific hosted agent session
as a Server-Sent Events (SSE) stream.

Each SSE frame contains:
- `event`: always `"log"`
- `data`: a plain-text log line (currently JSON-formatted, but the schema
is not contractual and may include additional keys or change format
over time — clients should treat it as an opaque string)

Example SSE frames:
```
event: log
data: {"timestamp":"2026-03-10T09:33:17.121Z","stream":"stdout","message":"Starting FoundryCBAgent server on port 8088"}

event: log
data: {"timestamp":"2026-03-10T09:33:17.130Z","stream":"stderr","message":"INFO: Application startup complete."}

event: log
data: {"timestamp":"2026-03-10T09:34:52.714Z","stream":"status","message":"Successfully connected to container"}

event: log
data: {"timestamp":"2026-03-10T09:35:52.714Z","stream":"status","message":"No logs since last 60 seconds"}
```

The stream remains open until the client disconnects or the server
terminates the connection. Clients should handle reconnection as needed.

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_name` | `string` | Yes | The name of the hosted agent. |
| `agent_version` | `string` | Yes | The version of the agent. |
| `session_id` | `string` | Yes | The session ID (maps to an ADC sandbox). |

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `api-version` | `string` | Yes | The API version to use for this operation. |

### Header parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Foundry-Features` | `enum` | No | A feature flag opt-in required when using preview operations or modifying persisted preview resources. _Constant:_ `HostedAgents=V1Preview` |

## Responses

### 200 — The request has succeeded.

Content-Type: `text/event-stream`

A single Server-Sent Event frame emitted by the hosted agent session log stream. Each frame contains an `event` field identifying the event type and a `data` field carrying the payload as plain text. Although the current `data` payload is JSON-formatted, its schema is not contractual — additional keys may appear and the format may change over time. Clients should treat `data` as an opaque string and optionally attempt JSON parsing. New event types may be added in the future. Clients should gracefully ignore unrecognized event types. Wire format: ``` event: log data: {"timestamp":"2026-03-10T09:33:17.121Z","stream":"stdout","message":"Starting server on port 18080"} event: log data: {"timestamp":"2026-03-10T09:34:52.714Z","stream":"status","message":"Successfully connected to container"} ```

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `event` | `enum` | Yes | The SSE event type. Currently `log`, but additional event types may be added in the future. Clients should ignore unrecognized event types. _Constant:_ `log` |
| `data` | `string` | Yes | The event payload as plain text. Currently JSON-formatted but the schema is not contractual and may change. |

### 4XX — Client error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |

### 5XX — Server error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |
