> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reportify.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch Stream Events

> Get assistant message events (streaming or non-streaming) from a specific offset

## 获取助手消息事件

**URL:** `/v1/agent/conversations/{conversation_id}/messages/{assistant_message_id}`
**方法:** `GET`
**描述:** 获取指定助手消息的所有事件，支持从指定的 offset 开始批量获取，可选择流式（SSE）或非流式（JSON）响应模式。

### 使用场景

* **断点续传**：当客户端断开连接后，可以从上次接收到的 offset 继续获取事件
* **历史回放**：获取已完成对话的完整事件历史
* **事件查询**：查询特定消息的所有事件，用于调试或分析

### 路径参数

| 参数名                    | 类型      | 必填 | 描述                                                        |
| ---------------------- | ------- | -- | --------------------------------------------------------- |
| conversation\_id       | integer | 是  | 对话 ID                                                     |
| assistant\_message\_id | string  | 是  | 助手消息 ID（从 chat 接口响应头 X-REPORTIFY-ASSISTANT-MESSAGE-ID 获取） |

### 查询参数

| 参数名          | 类型      | 必填 | 默认值  | 描述                  |
| ------------ | ------- | -- | ---- | ------------------- |
| stream       | boolean | 否  | true | 是否使用流式响应（SSE）       |
| timeout      | integer | 否  | 1800 | 流式模式的超时时间（秒）        |
| from\_offset | integer | 否  | 0    | 从指定偏移量开始获取事件（最小值：0） |

### 响应参数

#### 流式响应（stream=true）

返回 `text/event-stream` 格式的 SSE 流，每个事件的结构与 [智能体对话聊天接口](/api-reference/agent/conversation_chat) 相同。

#### 非流式响应（stream=false）

返回 JSON 格式的事件数组：

| 参数名               | 类型    | 描述                             |
| ----------------- | ----- | ------------------------------ |
| assistant\_events | array | 事件列表，每个元素为 WorkflowStreamEvent |

### 示例代码

#### cURL 示例（流式响应）

```bash theme={null}
curl -X GET "https://api.reportify.cn/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c?stream=true&from_offset=9200" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### cURL 示例（非流式响应）

```bash theme={null}
curl -X GET "https://api.reportify.cn/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c?stream=false&from_offset=9200" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

#### Python 示例（流式响应）

```python theme={null}
import requests

url = "https://api.reportify.cn/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}
params = {
    "stream": True,
    "from_offset": 9200
}

response = requests.get(url, headers=headers, params=params, stream=True)

for line in response.iter_lines():
    if line:
        line = line.decode('utf-8')
        if line.startswith('data: '):
            event_data = line[6:]  # 去掉 "data: " 前缀
            print(event_data)
```

#### Python 示例（非流式响应）

```python theme={null}
import requests

url = "https://api.reportify.cn/v1/agent/conversations/683242877840089/messages/019b24ef238cc97730971a9a0080c99c"
headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}
params = {
    "stream": False,
    "from_offset": 9200
}

response = requests.get(url, headers=headers, params=params)
data = response.json()

for event in data['assistant_events']:
    print(f"Event: {event['event_type']}, Offset: {event['offset']}")
```

### 响应示例

#### 非流式响应示例

```json theme={null}
{
  "assistant_events": [
    {
      "event_id": "019b24ef3046f157db389ee55a0a670a3797",
      "event_type": "streaming",
      "timestamp": 1765851213894,
      "response_id": "019b24ef238cc97730971a9a0080c99c",
      "workflow_id": "11887655289749510",
      "execution_id": "",
      "run_id": "019b24ef25015b3e6e9b3d2363cfb36c",
      "node_id": "start",
      "agent_id": "workflow_planner",
      "content": "项目的具体信息，并将这些信息整合到一份专业的AI行业每日深度报告中。",
      "offset": 9200
    },
    {
      "event_id": "019b24ef49d95c616af6a7b4953fc70a1129",
      "event_type": "node_start",
      "timestamp": 1765851220441,
      "response_id": "019b24ef238cc97730971a9a0080c99c",
      "workflow_id": "11887655289749510",
      "execution_id": "",
      "run_id": "019b24ef49d8a5997ea7d63b8344bfaa",
      "node_id": "define_report_scope",
      "node_name": "确定报告范围",
      "node_type": "agent",
      "offset": 9216
    }
  ]
}
```

## 注意事项

* `assistant_message_id` 可从对话聊天接口（stream=true）的 HTTP 响应头 `X-REPORTIFY-ASSISTANT-MESSAGE-ID` 中获取
* `from_offset` 参数用于指定从哪个偏移量开始获取事件，可以用于断点续传
* 流式模式下，事件会实时推送；非流式模式下，会一次性返回所有事件
* 建议在需要实时更新时使用流式模式，在需要批量处理历史数据时使用非流式模式


## OpenAPI

````yaml GET /v1/agent/conversations/{conversation_id}/messages/{assistant_message_id}
openapi: 3.1.0
info:
  title: Reportify API
  version: 1.0.0
  description: API documentation for Reportify's document management and search services.
servers:
  - url: https://api.reportify.cn
    description: Production server
security:
  - BearerAuth: []
paths:
  /v1/agent/conversations/{conversation_id}/messages/{assistant_message_id}:
    get:
      tags:
        - openapi-agent
      summary: Get Assistant Message Events
      description: >-
        Get assistant message events (streaming or non-streaming) from a
        specific offset
      operationId: >-
        get_assistant_message_events_reportify_api_v1_agent_conversations__conversation_id__messages__assistant_message_id__get
      parameters:
        - required: true
          schema:
            type: integer
            title: Conversation Id
            description: 对话 ID
          name: conversation_id
          in: path
          example: 683242877840089
        - required: true
          schema:
            type: string
            title: Assistant Message Id
            description: 助手消息 ID（从 chat 接口响应头 X-REPORTIFY-ASSISTANT-MESSAGE-ID 获取）
          name: assistant_message_id
          in: path
          example: 019b24ef238cc97730971a9a0080c99c
        - required: false
          schema:
            type: boolean
            title: Stream
            description: Stream events via SSE when true
            default: true
          name: stream
          in: query
          description: 是否使用流式响应（SSE）
        - required: false
          schema:
            type: integer
            title: Timeout
            description: Timeout in seconds for streaming mode
            default: 1800
          name: timeout
          in: query
          description: 流式模式的超时时间（秒）
        - required: false
          schema:
            type: integer
            minimum: 0
            title: From Offset
            description: Start streaming from specific offset
            default: 0
          name: from_offset
          in: query
          description: 从指定偏移量开始获取事件
          example: 9200
      responses:
        '200':
          description: Successful Response (Server-Sent Events stream or JSON array)
          content:
            text/event-stream:
              schema:
                $ref: '#/components/schemas/WorkflowStreamEvent'
            application/json:
              schema:
                type: object
                properties:
                  assistant_events:
                    type: array
                    items:
                      $ref: '#/components/schemas/WorkflowStreamEvent'
                    description: 事件列表
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    WorkflowStreamEvent:
      properties:
        event_id:
          type: string
          title: Event Id
          description: 唯一事件标识符
          example: 019b24ef23a1f4da18256b402868fae31764
        event_type:
          type: string
          title: Event Type
          description: 事件类型
          enum:
            - init
            - workflow_start
            - workflow_end
            - node_start
            - node_end
            - agent_start
            - agent_end
            - tool_start
            - tool_end
            - stream_start
            - streaming
            - stream_end
            - usage
            - cancel
            - error
          example: init
        timestamp:
          type: integer
          title: Timestamp
          description: 事件时间戳（毫秒）
          example: 1765851210657
        response_id:
          type: string
          title: Response Id
          description: 响应标识符，用于分组事件
          example: 019b24ef238cc97730971a9a0080c99c
        workflow_id:
          type: string
          title: Workflow Id
          description: 工作流标识符
          example: '11887655289749510'
        execution_id:
          type: string
          title: Execution Id
          description: 执行标识符
          example: 1dfccd9d-c365-4b7a-adae-aa9123684ec4
        run_id:
          type: string
          title: Run Id
          description: >-
            运行标识符，用于关联一组 start 和 end 事件（如 workflow_start 和
            workflow_end、tool_start 和 tool_end），用于分组相关的开始/结束事件对
          example: ''
        node_id:
          type: string
          title: Node Id
          description: 节点标识符
        node_name:
          type: string
          title: Node Name
          description: 节点显示名称
        node_type:
          type: string
          title: Node Type
          description: 节点类型（start, tool, agent, end）
        agent_id:
          type: string
          title: Agent Id
          description: 智能体标识符
        agent_name:
          type: string
          title: Agent Name
          description: 智能体显示名称
        agent_type:
          type: string
          title: Agent Type
          description: 智能体类型（builtin_agent, react_agent 等）
        tool_id:
          type: string
          title: Tool Id
          description: 工具标识符
        tool_name:
          type: string
          title: Tool Name
          description: 工具显示名称
        input:
          type: object
          title: Input
          description: 组件的输入数据
          properties:
            query:
              type: string
              description: 搜索查询
            symbols:
              type: array
              items:
                type: string
              description: 股票代码列表
            start_datetime:
              type: string
              description: 开始时间
            end_datetime:
              type: string
              description: 结束时间
            num:
              type: integer
              description: 返回数量
            filetype:
              type: string
              description: 文件类型
            response_mode:
              type: string
              description: 响应模式
          example:
            query: NVIDIA AMD Intel GPU 半导体 最新动态
            symbols:
              - US:NVDA
              - US:AMD
              - US:INTC
            start_datetime: '2025-12-15T00:00:00'
            end_datetime: '2025-12-16T02:14:15'
            num: 15
            filetype: json
        output:
          type: object
          title: Output
          description: >
            组件的输出数据。

            - 对于 tool_end 事件：包含 content 字段（JSON 字符串格式）

            - 对于 agent_end 事件：包含 content 字段（Markdown 格式）

            - 对于 node_end 事件：包含 content、filetype、filename、filepath 字段

            - 对于 workflow_end 事件：字典的 key 为最后一个 node 的 node_id，value 包含
            title、filetype、content、filename、filepath 字段
          properties:
            content:
              type: string
              description: 输出内容（JSON 字符串格式或 Markdown 格式）
          example:
            content: >-
              {"docs": [{"doc_id": "1197862772277383168", "title": "示例文档"}],
              "total_count": 10}
        content:
          type: string
          title: Content
          description: 事件内容（用于思考/流式输出）
          example: ''
        error:
          type: object
          title: Error
          description: 错误信息（如果事件类型为 error）
        offset:
          type: integer
          title: Offset
          description: 事件偏移量
          example: 9195
      type: object
      required:
        - event_id
        - event_type
        - timestamp
        - response_id
      title: WorkflowStreamEvent
      description: 工作流流式事件对象
      examples:
        - event_id: 019b24ef23a1f4da18256b402868fae31764
          event_type: init
          timestamp: 1765851210657
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: 1dfccd9d-c365-4b7a-adae-aa9123684ec4
          run_id: ''
          content: ''
          offset: 9195
        - event_id: 019b24ef24707069ef923d72561a95812188
          event_type: workflow_start
          timestamp: 1765851210864
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef246ef1f8e14609660d1d65be
          offset: 9196
        - event_id: 019b24ef24a481260ead20b3ff894a845363
          event_type: node_start
          timestamp: 1765851210916
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef24a4c38d39a09dee2eff830a
          node_id: start
          node_name: 开始
          node_type: start
          offset: 9197
        - event_id: 019b24ef4a297981a743b7f6dc55eb043579
          event_type: agent_start
          timestamp: 1765851220521
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef4a292fe173c0c73e0e334ce4
          node_id: define_report_scope
          node_name: 确定报告范围
          node_type: agent
          agent_id: agent_action
          agent_name: 执行智能体
          agent_type: action_agent
          offset: 9217
        - event_id: 019b24ef25014cbf7f25f0043effd82c6665
          event_type: stream_start
          timestamp: 1765851211009
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef25015b3e6e9b3d2363cfb36c
          node_id: start
          agent_id: workflow_planner
          offset: 9198
        - event_id: 019b24ef2e3b40bc070e30a4843987b35668
          event_type: streaming
          timestamp: 1765851213371
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef25015b3e6e9b3d2363cfb36c
          node_id: start
          agent_id: workflow_planner
          content: 你的任务是获取关于Google Gemini最新模型评分以及Google IDEA antigravity
          offset: 9199
        - event_id: 019b24f3717634bdd262947130af73b52555
          event_type: stream_end
          timestamp: 1765851492726
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24f348b67465f45353c50feb2367
          node_id: end
          agent_id: workflow_summarizer
          content: 本次工作流执行成功完成了任务，生成了一份全面的《AI行业每日深度报告》。
          offset: 9861
        - event_id: 019b24efea2a626e2cb6f9c22b2683bb9594
          event_type: tool_start
          timestamp: 1765851261482
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24efea2a3e491e920de6003caf6c_5hyy41
          node_id: collect_upstream_news
          agent_id: agent_deep_search
          tool_id: tool_news_search
          tool_name: 新闻搜索
          input:
            query: NVIDIA AMD Intel GPU 半导体 最新动态
            symbols:
              - US:NVDA
              - US:AMD
              - US:INTC
            start_datetime: '2025-12-15T00:00:00'
            end_datetime: '2025-12-16T02:14:15'
            num: 15
            filetype: json
          offset: 9323
        - event_id: 019b24efec9274b499f96da757fb03a66788
          event_type: tool_end
          timestamp: 1765851262098
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24efdf9629d550ae7803264e3589_n1rz9t
          node_id: collect_model_layer_news
          agent_id: agent_deep_search
          tool_id: tool_news_search
          tool_name: 新闻搜索
          output:
            content: >-
              {"docs": [{"doc_id": "1197862772277383168", "title": "示例文档"}],
              "total_count": 10}
        - event_id: 019b24efc138c7b1e3adc456762dda377273
          event_type: agent_end
          timestamp: 1765851251000
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef4a292fe173c0c73e0e334ce4
          node_id: define_report_scope
          node_name: 确定报告范围
          node_type: agent
          agent_id: agent_action
          agent_name: 执行智能体
          agent_type: action_agent
          output:
            content: |-
              # AI行业每日深度报告 - 覆盖范围与重点标的清单

              ## 报告概述
              本报告将全面覆盖AI全产业链上下游...
          offset: 9264
        - event_id: 019b24f3719913f41c7d391a00efe55a2581
          event_type: node_end
          timestamp: 1765851492761
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24f3485b8f786c3da7168d826202
          node_id: end
          node_name: 结束
          node_type: end
          output:
            content: 本次工作流执行成功完成了任务，生成了一份全面的《AI行业每日深度报告》。
          offset: 9863
        - event_id: 019b24f371b1d3759377966a35173d099385
          event_type: workflow_end
          timestamp: 1765851492785
          response_id: 019b24ef238cc97730971a9a0080c99c
          workflow_id: '11887655289749510'
          execution_id: ''
          run_id: 019b24ef246ef1f8e14609660d1d65be
          output:
            generate_daily_report:
              title: AI行业每日深度报告 - 2025年12月16日
              filetype: markdown
              content: |-
                # AI行业每日深度报告 - 2025年12月16日

                ## 执行摘要
                ...
              filename: AI行业每日深度报告 - 2025年12月16日.md
              filepath: /AI行业每日深度报告 - 2025年12月16日.md
          offset: 9864
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your Bearer token

````