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

# 将会话写入记忆

> 将 sessionId 对应会话交给配置的记忆服务处理；成功返回 JSON null

先确认服务已配置记忆后端，并使用同一应用、用户下的有效 `sessionId`。未配置记忆服务返回 `400`，会话不存在返回 `404`

<Warning>
  此操作将会话事件交给已配置的记忆服务保存或处理，后续检索可能使用这些内容。提交前确认会话包含的数据适合写入该后端
</Warning>

成功返回 JSON `null`，表示写入调用已完成；返回体不包含提取出的记忆，也不保证后续检索一定命中这些内容


## OpenAPI

````yaml productions/api-reference/openapi/zh/agent-api-server.json PATCH /apps/{app_name}/users/{user_id}/memory
openapi: 3.1.0
info:
  title: Agent API Server
  version: google-adk 2.2.0
  description: 基于 Google ADK 2.2.0 的公开 HTTP 接口；/dev 路由仅在启用开发界面的服务中可用
servers:
  - url: http://localhost:8000
    description: 本地服务
security: []
tags:
  - name: 服务与应用
  - name: 会话
  - name: 智能体运行
  - name: 制品
  - name: 记忆
  - name: 评测 · 开发服务
  - name: 调试 · 开发服务
  - name: 兼容接口
paths:
  /apps/{app_name}/users/{user_id}/memory:
    patch:
      tags:
        - 记忆
      summary: 将会话写入记忆
      description: 将 sessionId 对应会话交给配置的记忆服务处理；成功返回 JSON null
      operationId: agentApiUpdateMemory
      parameters:
        - name: app_name
          in: path
          required: true
          schema:
            type: string
            title: App Name
          description: 应用名称
          example: travel_assistant
        - name: user_id
          in: path
          required: true
          schema:
            type: string
            title: User Id
          description: 用户 ID
          example: user-001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMemoryRequest'
            example:
              sessionId: session-001
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                type: 'null'
              example: null
        '400':
          description: 请求不符合接口要求，或所需服务/依赖未配置
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: 请求的资源不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '422':
          description: 请求参数验证失败
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UpdateMemoryRequest:
      properties:
        sessionId:
          type: string
          title: Sessionid
          description: 会话 ID
      type: object
      required:
        - sessionId
      title: UpdateMemoryRequest
    ApiError:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误详情
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          description: 错误详情
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: 出错字段的位置
        msg:
          type: string
          title: Message
          description: 验证错误说明
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````