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

# 更新记忆存储

> 通过 OMA API 更新记忆存储。

<Info>每个请求都必须发送 `?beta=true`。</Info>


## OpenAPI

````yaml /openapi/oma.zh.json post /v1/memory_stores/{memory_store_id}
openapi: 3.1.0
info:
  title: OMA API 参考
  version: 1.0.0
  description: Open Managed Agents 应用 API 参考。
servers:
  - url: http://localhost:38080
    description: 本地 OMA 服务器
security:
  - omaApiKey: []
  - omaBearer: []
paths:
  /v1/memory_stores/{memory_store_id}:
    post:
      summary: 更新记忆存储
      operationId: BetaUpdateMemoryStore
      parameters:
        - name: beta
          in: query
          required: true
          description: 为此接口启用 Beta API 合同，必须为 `true`。
          schema:
            type: boolean
            enum:
              - true
        - name: anthropic-version
          in: header
          required: false
          schema:
            type: string
        - name: anthropic-beta
          in: header
          required: false
          schema:
            type: string
            items:
              type: string
            x-stainless-override-schema:
              x-stainless-param: betas
              x-stainless-extend-default: true
              type: array
              description: 用于指定一个或多个 Beta 版本的可选请求头。
              items:
                $ref: '#/components/schemas/AnthropicBeta'
            x-default: agent-memory-2026-07-22
        - name: memory_store_id
          in: path
          required: true
          schema:
            type: string
            x-stainless-cli-data-alias: id
          description: 记忆存储标识符。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/BetaManagedAgentsUpdateMemoryStoreRequestBody
      responses:
        '200':
          description: 请求成功。
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BetaManagedAgentsUpdateMemoryStoreResponse
        '400':
          description: Invalid argument - 客户端指定了无效的参数
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '401':
          description: 未认证 - 请求没有有效的认证凭据
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '403':
          description: 权限被拒绝 - 调用方没有执行指定操作的权限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '404':
          description: 未找到 - 请求的某个实体不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '408':
          description: 超出截止时间 - 截止时间在操作完成之前已过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '409':
          description: 已中止 - 该操作因并发问题而被中止
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '412':
          description: 前置条件不满足 - 由于系统未处于所需状态，操作被拒绝
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '413':
          description: Out of range - 尝试的操作超出了有效范围
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '429':
          description: 资源耗尽 - 某些资源已被耗尽（限流）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '431':
          description: 请求头字段过大 - 请求元数据过大
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '499':
          description: Cancelled - 操作已被客户端取消
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '500':
          description: Internal - 内部服务器错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '501':
          description: 未实现 - 该操作未实现或不受支持
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '503':
          description: 不可用 - 服务当前不可用
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
        '504':
          description: 超时 - 上游服务未及时响应
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetaErrorResponse'
components:
  schemas:
    BetaManagedAgentsUpdateMemoryStoreRequestBody:
      type: object
      additionalProperties: false
      properties:
        name:
          description: >-
            存储的新的人类可读名称。1–255 个字符；不允许控制字符。重命名会更改该存储在更新之后创建的会话中用于 `mount_path` 的
            slug。
          type: string
          minLength: 1
          maxLength: 255
          nullable: true
        description:
          description: 存储的新描述，最多 1024 个字符。传入空字符串可将其清除。
          type: string
          maxLength: 1024
          nullable: true
        metadata:
          description: >-
            元数据补丁。将某个键设为字符串以插入或更新该键，设为 null 以删除该键。省略该字段则保持不变。存储的元数据集合最多 16
            个键（每个键最多 64 个字符），值最多 512 个字符。
          type: object
          additionalProperties:
            type: string
            nullable: true
          nullable: true
    BetaManagedAgentsUpdateMemoryStoreResponse:
      description: 更新 `memory_store` 的响应。返回已应用变更的存储。
      type: object
      discriminator:
        propertyName: type
        mapping:
          memory_store:
            $ref: '#/components/schemas/BetaManagedAgentsMemoryStore'
      oneOf:
        - $ref: '#/components/schemas/BetaManagedAgentsMemoryStore'
    BetaErrorResponse:
      properties:
        error:
          discriminator:
            mapping:
              api_error:
                $ref: '#/components/schemas/BetaAPIError'
              authentication_error:
                $ref: '#/components/schemas/BetaAuthenticationError'
              billing_error:
                $ref: '#/components/schemas/BetaBillingError'
              invalid_request_error:
                $ref: '#/components/schemas/BetaInvalidRequestError'
              not_found_error:
                $ref: '#/components/schemas/BetaNotFoundError'
              overloaded_error:
                $ref: '#/components/schemas/BetaOverloadedError'
              permission_error:
                $ref: '#/components/schemas/BetaPermissionError'
              rate_limit_error:
                $ref: '#/components/schemas/BetaRateLimitError'
              timeout_error:
                $ref: '#/components/schemas/BetaGatewayTimeoutError'
            propertyName: type
          oneOf:
            - $ref: '#/components/schemas/BetaInvalidRequestError'
            - $ref: '#/components/schemas/BetaAuthenticationError'
            - $ref: '#/components/schemas/BetaBillingError'
            - $ref: '#/components/schemas/BetaPermissionError'
            - $ref: '#/components/schemas/BetaNotFoundError'
            - $ref: '#/components/schemas/BetaRateLimitError'
            - $ref: '#/components/schemas/BetaGatewayTimeoutError'
            - $ref: '#/components/schemas/BetaAPIError'
            - $ref: '#/components/schemas/BetaOverloadedError'
          title: 错误
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: 请求 ID
        type:
          const: error
          default: error
          title: 类型
          type: string
      required:
        - error
        - request_id
        - type
      title: ErrorResponse
      type: object
    BetaManagedAgentsMemoryStore:
      description: >-
        `memory_store`：智能体记忆的命名容器，作用域为工作区。通过 `resources[]`
        将存储附加到会话，即可将其挂载为智能体可读写的目录。
      type: object
      additionalProperties: false
      required:
        - type
        - id
        - name
        - created_at
        - updated_at
      properties:
        type:
          type: string
          enum:
            - memory_store
        id:
          description: >-
            记忆存储的唯一标识符（带 `memstore_...` 标记的 ID）。将存储附加到会话时，或在后续调用的
            `{memory_store_id}` 路径参数中，请使用该值。
          type: string
        name:
          description: 存储的人类可读名称。1–255 个字符。该存储在 `/mnt/memory/` 下的挂载路径 slug 由此名称派生。
          type: string
        description:
          description: 描述存储内容的自由文本，最多 1024 个字符。当存储被附加时会包含在智能体的系统提示词中，因此措辞应对智能体有用。未设置时为空字符串。
          type: string
        created_at:
          description: 存储创建的时间戳。
          allOf:
            - $ref: '#/components/schemas/BetaTimestamp'
        updated_at:
          description: 该存储的 `name`、`description` 或 `metadata` 最后一次修改的时间戳。存储内部的记忆写入不会更新此时间戳。
          allOf:
            - $ref: '#/components/schemas/BetaTimestamp'
        metadata:
          description: >-
            供你自己记录使用的任意键值标签（例如存储所属的终端用户）。最多 16 对；键为 1–64 个字符；值最多 512 个字符。在
            retrieve/list 时返回，但不可用于过滤。
          type: object
          additionalProperties:
            type: string
        archived_at:
          description: 存储被归档时的时间戳，处于活跃状态时为 `null`。一经设置便不会清除；归档是单向的。已归档的存储为只读，且无法附加到新的会话。
          allOf:
            - $ref: '#/components/schemas/BetaTimestamp'
          nullable: true
    BetaAPIError:
      properties:
        message:
          default: Internal server error
          title: 消息
          type: string
        type:
          const: api_error
          default: api_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: APIError
      type: object
    BetaAuthenticationError:
      properties:
        message:
          default: Authentication error
          title: 消息
          type: string
        type:
          const: authentication_error
          default: authentication_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: AuthenticationError
      type: object
    BetaBillingError:
      properties:
        message:
          default: Billing error
          title: 消息
          type: string
        type:
          const: billing_error
          default: billing_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: BillingError
      type: object
    BetaInvalidRequestError:
      properties:
        message:
          default: Invalid request
          title: 消息
          type: string
        type:
          const: invalid_request_error
          default: invalid_request_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: InvalidRequestError
      type: object
    BetaNotFoundError:
      properties:
        message:
          default: Not found
          title: 消息
          type: string
        type:
          const: not_found_error
          default: not_found_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: NotFoundError
      type: object
    BetaOverloadedError:
      properties:
        message:
          default: Overloaded
          title: 消息
          type: string
        type:
          const: overloaded_error
          default: overloaded_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: OverloadedError
      type: object
    BetaPermissionError:
      properties:
        message:
          default: Permission denied
          title: 消息
          type: string
        type:
          const: permission_error
          default: permission_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: PermissionError
      type: object
    BetaRateLimitError:
      properties:
        message:
          default: Rate limited
          title: 消息
          type: string
        type:
          const: rate_limit_error
          default: rate_limit_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: RateLimitError
      type: object
    BetaGatewayTimeoutError:
      properties:
        message:
          default: Request timeout
          title: 消息
          type: string
        type:
          const: timeout_error
          default: timeout_error
          title: 类型
          type: string
      required:
        - message
        - type
      title: GatewayTimeoutError
      type: object
    BetaTimestamp:
      description: RFC 3339 格式的时间戳
      type: string
      format: date-time
  securitySchemes:
    omaApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: OMA 工作区 API 密钥。
      x-default: sk-ant-local-default
    omaBearer:
      type: http
      scheme: bearer
      description: 以 Bearer 令牌形式发送的 OMA 工作区 API 密钥。

````