Repository navigation
Description
Before opening, please confirm
- I have searched for duplicate or closed issues.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Which package(s) are affected?
Other (@aws-blocks/bb-knowledge-base)
Describe the bug
The local KnowledgeBase (a keyword index over the source folder) doesn't apply the Bedrock Knowledge Bases request limits, and its waitUntilSynced() ignores its options:
| Call | Local | Deployed |
|---|---|---|
retrieve(<20,001-character query>) |
ok, 3 results | KnowledgeBaseValidationError (query text max 20,000) |
retrieve(q, { filter: { [<101-character key>]: { equals: 'x' } } }) |
ok, 0 results | KnowledgeBaseValidationError (filter key 1 to 100 characters) |
waitUntilSynced({ signal }) with an already-aborted signal |
resolves | rejects with AbortError |
The first two matter for apps that pass user input (a pasted document, a filter built from form fields) straight to retrieve(). The third breaks the documented contract ("An already-aborted signal rejects immediately, before any polling"), so cancellation logic can't be tested locally.
(Ranking and chunk text also differ, which is expected from a keyword index versus vector search and is not part of this report.)
Expected behavior
The mock validates query length and filter key length with the same KnowledgeBaseValidationError, and waitUntilSynced() honors signal (and timeoutMs) the same way the AWS implementation does, even though the local index is always in sync.
Reproduction steps
const kb = new KnowledgeBase(scope, 'docs', { source: './knowledge', description: 'Docs' });
await kb.retrieve('word '.repeat(4001)); // ok locally, KnowledgeBaseValidationError deployed
await kb.retrieve('setup', { filter: { ['k'.repeat(101)]: { equals: 'x' } } }); // same
const c = new AbortController(); c.abort();
await kb.waitUntilSynced({ signal: c.signal }); // resolves locally, AbortError deployedEnvironment
@aws-blocks/*0.8.0 (mainat 34e758c)- Local:
npm run devdev server, Node 22, macOS - Deployed: a sandbox stack in us-east-1
Additional context
- https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_KnowledgeBaseQuery.html (text max length 20,000), https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_FilterAttribute.html (key length 1 to 100).
- Likely location:
retrieve()andwaitUntilSynced(_options)inpackages/bb-knowledge-base/src/index.mock.ts(line 277 ignores the options).
Activity