CAMEL-23466: camel-aws-bedrock-agent-runtime - Add retrieve operation#23147
Conversation
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
All tested modules (10 modules)
|
gnodet
left a comment
There was a problem hiding this comment.
Nice, clean addition — the retrieve operation fills a real gap and follows the existing producer patterns well. Tests, docs, and regenerated artifacts all look solid. A couple of minor observations below (both non-blocking).
This review covers project conventions, code patterns, test coverage, and documentation. It does not replace specialized review tools (CodeRabbit, Sourcery) or static analysis (SonarCloud).
Claude Code on behalf of Guillaume Nodet
| invokeFlow(exchange); | ||
| break; | ||
| case retrieve: | ||
| retrieve(getEndpoint().getBedrockAgentRuntimeClient(), exchange); |
There was a problem hiding this comment.
Nit: minor style inconsistency — the existing retrieveAndGenerate and invokeFlow cases call their methods with just exchange, and those methods fetch the client internally via getEndpoint().getBedrockAgentRuntimeClient(). Here the client is resolved at the call site and passed in as a parameter.
Not a functional issue at all, just a pattern mismatch that caught my eye. Feel free to ignore.
Claude Code on behalf of Guillaume Nodet
| .build(); | ||
| return RetrieveResponse.builder() | ||
| .retrievalResults(result) | ||
| .nextToken("page-2-token") |
There was a problem hiding this comment.
The mock response exercises the nextToken path nicely, but the guardrailAction response-handling path in prepareRetrieveResponse is never covered — the mock response does not set a guardrail action, so the RETRIEVE_GUARDRAIL_ACTION header branch is untested.
Consider either adding .guardrailAction(...) to this mock response (and asserting the header in the first test), or adding a small dedicated test with its own mock response that includes a guardrail action. Low priority but would close the gap.
Claude Code on behalf of Guillaume Nodet
Summary
Adds the
retrieveoperation to thecamel-aws-bedrock-agent-runtimecomponent.The component previously only exposed
retrieveAndGenerate(semantic search + LLMgeneration) and
invokeFlow. The BedrockRetrieveAPI — semantic search againsta knowledge base returning the matched chunks without invoking a model — was
missing despite already being supported by the underlying SDK
(
BedrockAgentRuntimeClient.retrieve(RetrieveRequest)).This is a common operation when users want to plug in their own generation step,
inspect retrieval quality, or paginate through knowledge-base hits.
Changes
BedrockAgentRuntimeOperations: newretrievevalue.BedrockAgentRuntimeProducer:process(...)and routes to a newretrieve(...)method;Stringbody = query text, knobs via headers) andPOJO mode (
pojoRequest=true→ body is aRetrieveRequest, forwarded verbatim).List<KnowledgeBaseRetrievalResult>) plusa
RETRIEVED_RESULTSheader for parity with the existingCITATIONSpattern.BedrockAgentRuntimeConstants: new headersCamelAwsBedrockAgentRuntimeRetrievedResults— the matched chunks.CamelAwsBedrockAgentRuntimeNumberOfResults— overridesnumberOfResults.CamelAwsBedrockAgentRuntimeSearchType— overridesoverrideSearchType(HYBRID/SEMANTIC).CamelAwsBedrockAgentRuntimeNextToken— pagination token (in + out).CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction— guardrail action when present.overrideSearchType, nextToken), failure when
knowledgeBaseIdis missing, and POJO mode.aws-bedrock-agent-runtime-component.adoc.JIRA: https://issues.apache.org/jira/browse/CAMEL-23466
Test plan
mvn clean installfrom the module directory — module tests green (4 new + existing).mvn clean install -DskipTestsfrom the repo root — full reactor build green.Claude Code on behalf of Andrea Cosentino