Skip to content

list_memory_records

list_memory_records(
    memory_id: MemoryId,
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    namespace: Optional[Namespace] = None,
    namespace_path: Optional[Namespace] = None,
    memory_strategy_id: Optional[MemoryStrategyId] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
    metadata_filters: Optional[MemoryMetadataFilterList] = None,
) -> ListMemoryRecordsOutput

Lists memory records in an AgentCore Memory resource based on specified criteria. We recommend using pagination to ensure that the operation returns quickly and successfully.

To use this operation, you must have the bedrock-agentcore:ListMemoryRecords permission.

Parameters:

  • memory_id (MemoryId) –

    The identifier of the AgentCore Memory resource for which to list memory records.

  • namespace (Optional[Namespace], default: None ) –

    The namespace prefix to filter memory records by. Returns all memory records in namespaces that start with the provided prefix. Either namespace or namespacePath is required.

  • namespace_path (Optional[Namespace], default: None ) –

    Use namespacePath for hierarchical retrievals. Return all memory records where namespace falls under the same parent hierarchy. Either namespace or namespacePath is required.

  • memory_strategy_id (Optional[MemoryStrategyId], default: None ) –

    The memory strategy identifier to filter memory records by. If specified, only memory records with this strategy ID are returned.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return in a single call. The default value is 20.

  • next_token (Optional[PaginationToken], default: None ) –

    The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

  • metadata_filters (Optional[MemoryMetadataFilterList], default: None ) –

    A list of metadata filter expressions to scope the returned memory records.

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.

  • InvalidInputException –

    The input fails to satisfy the constraints specified by AgentCore. Check your input values and try again.

  • 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 list_memory_records(
    self,
    memory_id: "capo_bedrock_agentcore.types.memory_id.MemoryId",
    *,
    config_overrides: Optional[BedrockAgentCoreClientConfig] = None,
    namespace: Optional["capo_bedrock_agentcore.types.namespace.Namespace"] = None,
    namespace_path: Optional[
        "capo_bedrock_agentcore.types.namespace.Namespace"
    ] = None,
    memory_strategy_id: Optional[
        "capo_bedrock_agentcore.types.memory_strategy_id.MemoryStrategyId"
    ] = None,
    max_results: Optional[
        "capo_bedrock_agentcore.types.max_results.MaxResults"
    ] = None,
    next_token: Optional[
        "capo_bedrock_agentcore.types.pagination_token.PaginationToken"
    ] = None,
    metadata_filters: Optional[
        "capo_bedrock_agentcore.types.memory_metadata_filter_list.MemoryMetadataFilterList"
    ] = None,
) -> "capo_bedrock_agentcore.types.list_memory_records_output.ListMemoryRecordsOutput":
    """<p>Lists memory records in an AgentCore Memory resource based on specified criteria. We recommend using pagination to ensure that the operation returns quickly and successfully.</p> <p>To use this operation, you must have the <code>bedrock-agentcore:ListMemoryRecords</code> permission.</p>

    Args:
        memory_id: <p>The identifier of the AgentCore Memory resource for which to list memory records.</p>
        namespace: <p>The namespace prefix to filter memory records by. Returns all memory records in namespaces that start with the provided prefix. Either <code>namespace</code> or <code>namespacePath</code> is required.</p>
        namespace_path: <p>Use namespacePath for hierarchical retrievals. Return all memory records where namespace falls under the same parent hierarchy. Either <code>namespace</code> or <code>namespacePath</code> is required.</p>
        memory_strategy_id: <p>The memory strategy identifier to filter memory records by. If specified, only memory records with this strategy ID are returned.</p>
        max_results: <p>The maximum number of results to return in a single call. The default value is 20.</p>
        next_token: <p>The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.</p>
        metadata_filters: <p>A list of metadata filter expressions to scope the returned memory records.</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.invalid_input_exception.InvalidInputException: <p>The input fails to satisfy the constraints specified by AgentCore. Check your input values and try again.</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.list_memory_records_input.ListMemoryRecordsInput]",
    ) -> OperationResponse[
        "capo_bedrock_agentcore.types.list_memory_records_output.ListMemoryRecordsOutput"
    ]:
        import capo_bedrock_agentcore._operations.amazon_bedrock_agent_core.list_memory_records

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

    def _redact_output(
        output: "capo_bedrock_agentcore.types.list_memory_records_output.ListMemoryRecordsOutput",
    ) -> dict[str, Any]:
        import capo_bedrock_agentcore.types.list_memory_records_output

        return capo_bedrock_agentcore.types.list_memory_records_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListMemoryRecords", redact_output=_redact_output),
    )
    input_: capo_bedrock_agentcore.types.list_memory_records_input.ListMemoryRecordsInput = {
        "memory_id": memory_id
    }
    if namespace is not None:
        input_["namespace"] = namespace
    if namespace_path is not None:
        input_["namespace_path"] = namespace_path
    if memory_strategy_id is not None:
        input_["memory_strategy_id"] = memory_strategy_id
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if metadata_filters is not None:
        input_["metadata_filters"] = metadata_filters

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