Skip to content

batch_update_memory_records

batch_update_memory_records(
    memory_id: MemoryId,
    records: MemoryRecordsUpdateInputList,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    record_expiry_specification: Optional[RecordExpirySpecification] = None,
) -> BatchUpdateMemoryRecordsOutput

Updates multiple memory records with custom content in a single batch operation within the specified memory.

Parameters:

  • memory_id (MemoryId) –

    The unique ID of the memory resource where records will be updated.

  • records (MemoryRecordsUpdateInputList) –

    A list of memory record update inputs to be processed in the batch operation.

  • record_expiry_specification (Optional[RecordExpirySpecification], default: None ) –

    The record expiry (long-term memory time-to-live) applied to every record updated by this request. Set recordExpiryDurationDays to configure or overwrite the number of days after which the records expire, or set action to REMOVE to clear a previously configured expiry so that the records no longer expire.

    When you do not provide this value, the service determines each record's expiry from its current state:

    • If the record already has an expiry configured, the service resets and reapplies the expiry based on the last applied recordExpiryDurationDays.

    • If the record does not have an expiry configured, no expiry is applied and the record remains non-expiring. This is the outcome regardless of whether the record's strategy configures an expiry.

    Providing an explicit recordExpiryDurationDays always takes precedence: it overwrites an existing expiry, or sets one on a record that previously had none.

Raises:

  • AccessDeniedException –

    The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.

  • ResourceNotFoundException –

    The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.

  • ServiceException –

    The service encountered an internal error. Try your request again later.

  • ServiceQuotaExceededException –

    The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.

  • ThrottledException –

    The request was denied due to request throttling. Reduce the frequency of requests and try again.

  • ValidationException –

    The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_bedrock_agentcore/_services/bedrock_agent_core.py
def batch_update_memory_records(
    self,
    memory_id: "capo_bedrock_agentcore.types.memory_id.MemoryId",
    records: "capo_bedrock_agentcore.types.memory_records_update_input_list.MemoryRecordsUpdateInputList",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    record_expiry_specification: Optional[
        "capo_bedrock_agentcore.types.record_expiry_specification.RecordExpirySpecification"
    ] = None,
) -> "capo_bedrock_agentcore.types.batch_update_memory_records_output.BatchUpdateMemoryRecordsOutput":
    """<p>Updates multiple memory records with custom content in a single batch operation within the specified memory.</p>

    Args:
        memory_id: <p>The unique ID of the memory resource where records will be updated.</p>
        records: <p>A list of memory record update inputs to be processed in the batch operation.</p>
        record_expiry_specification: <p>The record expiry (long-term memory time-to-live) applied to every record updated by this request. Set <code>recordExpiryDurationDays</code> to configure or overwrite the number of days after which the records expire, or set <code>action</code> to <code>REMOVE</code> to clear a previously configured expiry so that the records no longer expire.</p> <p>When you do not provide this value, the service determines each record's expiry from its current state:</p> <ul> <li> <p>If the record already has an expiry configured, the service resets and reapplies the expiry based on the last applied <code>recordExpiryDurationDays</code>.</p> </li> <li> <p>If the record does not have an expiry configured, no expiry is applied and the record remains non-expiring. This is the outcome regardless of whether the record's strategy configures an expiry.</p> </li> </ul> <p>Providing an explicit <code>recordExpiryDurationDays</code> always takes precedence: it overwrites an existing expiry, or sets one on a record that previously had none.</p>

    Raises:
        capo_bedrock_agentcore.errors.access_denied_exception.AccessDeniedException: <p>The exception that occurs when you do not have sufficient permissions to perform an action. Verify that your IAM policy includes the necessary permissions for the operation you are trying to perform.</p>
        capo_bedrock_agentcore.errors.resource_not_found_exception.ResourceNotFoundException: <p>The exception that occurs when the specified resource does not exist. This can happen when using an invalid identifier or when trying to access a resource that has been deleted.</p>
        capo_bedrock_agentcore.errors.service_exception.ServiceException: <p>The service encountered an internal error. Try your request again later.</p>
        capo_bedrock_agentcore.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The exception that occurs when the request would cause a service quota to be exceeded. Review your service quotas and either reduce your request rate or request a quota increase.</p>
        capo_bedrock_agentcore.errors.throttled_exception.ThrottledException: <p>The request was denied due to request throttling. Reduce the frequency of requests and try again.</p>
        capo_bedrock_agentcore.errors.validation_exception.ValidationException: <p>The exception that occurs when the input fails to satisfy the constraints specified by the service. Check the error message for details about which input parameter is invalid and correct your request.</p>
        capo_bedrock_agentcore.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_bedrock_agentcore.types.batch_update_memory_records_input.BatchUpdateMemoryRecordsInput]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.batch_update_memory_records_output.BatchUpdateMemoryRecordsOutput"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.batch_update_memory_records

        output, http_response = (
            capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.batch_update_memory_records.batch_update_memory_records(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agentcore.types.batch_update_memory_records_input.BatchUpdateMemoryRecordsInput",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore.types.batch_update_memory_records_input

        return capo_bedrock_agentcore.types.batch_update_memory_records_input.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("BatchUpdateMemoryRecords", redact_input=_redact_input),
    )
    input_: capo_bedrock_agentcore.types.batch_update_memory_records_input.BatchUpdateMemoryRecordsInput = {
        "memory_id": memory_id,
        "records": records,
    }
    if record_expiry_specification is not None:
        input_["record_expiry_specification"] = record_expiry_specification

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output