Skip to content

Limit on number of filters passed into invoke agent

0

When using the Invoke Agent API of Bedrock, we have an option to pass in filters. Is there any hard limit on the number of filters that we can pass to the agent or the Bedrock Knowledge base.

2 Answers
1

Good Day,

It is possible to add multiple filters, I was able to add multiple filters (8 filters) to use for the Agent/KnowledgeBase.

Summary of test:

Filters can be applied within the vectorSearchConfiguration of a knowledge base configuration in the SessionState object. They must follow a specific structure using "key" and "value" parameters.

Filters are defined using operators like equals, startsWith, and can be combined using andAll and orAll.

Each filter operation requires:

  • A specific operator (equals, startsWith, etc.)
  • A key parameter
  • A value parameter

Example of a working Verified Filter Structure:

{
    "filterType": {
        "key": "fieldname",
        "value": "fieldvalue"
    }
}

Working Example of Complex Filter:

{
    "andAll": [
        {
            "orAll": [
                {
                    "equals": {
                        "key": "filename",
                        "value": "fieldvalue"
                    }
                },
                {
                    "stringContains": {
                        "key": "filename",
                        "value": "fieldvalue"
                    }
                }
            ]
        },
        {
            "notEquals": {
                "key": "filename",
                "value": "example.pdf"
            }
        }
    ]
}

Multiple filters can be combined using andAll, all tests results returned '200 OK' with the filtered information as requested.

As we do not see any documentation for a hard limit, the test with 8 filters was successful.

For more assistance with this request, kindly log a case with AWS Premium Support and we will be able to assist further with more information on the environment and KB + Agent data.

Have a good day.

answered a year ago

EXPERT

reviewed a year ago

  • Thanks for the response. I had also tried it from my end to find if there are my limitations to the number of filters that can be passed. I did try to pass in multiple filters over 15 of them and it worked just fine. But there are some limitations that I had found out which I would like to highlight.

    1. The number of nesting layers cannot be more than 2.
    2. The logical operator in the same level of nest has to be the same.

    These are some of the limitations that I found from my side while using the UI or any of the agent invocation APIs (Invoke_agent/Retrieve/RetrieveandGenerate)

    Have a good day.

0

When using the InvokeAgent API for Amazon Bedrock, there isn't a specific hard limit mentioned for the number of filters you can pass to the agent or the Bedrock Knowledge Base. However, it's important to note that there are some considerations and limitations when working with filters in Bedrock agents:

  1. Filters can be applied as part of the SessionState object, which agents use. This allows you to set up filters that can be used throughout the agent session.

  2. The filters are typically defined within the retrievalConfiguration of the knowledgeBases section in the SessionState object.

  3. You can use various filter types, including equals, greaterThan, in, startsWith, and combine them using andAll and orAll operators to create complex filter conditions.

  4. While there's no explicit limit on the number of filters, it's generally a good practice to keep your filter complexity manageable. Extremely complex or numerous filters might impact performance or readability.

  5. The overall size and complexity of your request, including filters, may be subject to API limits or timeouts. The InvokeAgent request has a default timeout of 60 seconds.

If you find that you need to use a large number of filters and are concerned about potential limitations, it would be advisable to test your use case thoroughly and, if necessary, contact AWS Support for guidance specific to your implementation. They can provide more detailed information about any practical limits that might apply to your particular scenario.
Sources
Bedrock Agent with knowledgebase metadata search | AWS re:Post
What is the quota of InvokeAgent calls in Bedrock? | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.