This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 5cc87cb60862 CAMEL-23466: camel-aws-bedrock-agent-runtime - Add
retrieve operation (#23147)
5cc87cb60862 is described below
commit 5cc87cb608627f1883edabbd331aa27b3403fa8a
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue May 12 15:08:32 2026 +0200
CAMEL-23466: camel-aws-bedrock-agent-runtime - Add retrieve operation
(#23147)
Add the `retrieve` operation to camel-aws-bedrock-agent-runtime, exposing
the
Bedrock Retrieve API for semantic search against a knowledge base without
invoking a model. Previously only `retrieveAndGenerate` and `invokeFlow`
were
available, even though the underlying SDK already supported retrieve.
Supports both header-driven mode (String body as query; numberOfResults,
overrideSearchType, nextToken via headers) and POJO mode (body is a
verbatim RetrieveRequest). Results are exposed on the out-message body and
mirrored on a new RETRIEVED_RESULTS header for parity with the existing
CITATIONS pattern. New headers added for the matched chunks, result count,
search type, pagination token, and guardrail action.
Includes unit tests for default request building, header overrides,
missing-knowledgeBaseId failure, and POJO mode. Catalog JSON, endpoint DSL,
and component docs regenerated/updated accordingly.
Closes #23147
---
.../components/aws-bedrock-agent-runtime.json | 11 +-
.../catalog/components/aws-bedrock-agent.json | 7 +-
.../aws2/bedrock/agent/aws-bedrock-agent.json | 7 +-
.../agentruntime/aws-bedrock-agent-runtime.json | 11 +-
.../docs/aws-bedrock-agent-runtime-component.adoc | 27 +++
.../agentruntime/BedrockAgentRuntimeConstants.java | 25 +++
.../BedrockAgentRuntimeOperations.java | 3 +-
.../agentruntime/BedrockAgentRuntimeProducer.java | 84 +++++++++
.../BedrockAgentRuntimeProducerRetrieveTest.java | 210 +++++++++++++++++++++
.../dsl/BedrockAgentEndpointBuilderFactory.java | 74 ++++++++
.../BedrockAgentRuntimeEndpointBuilderFactory.java | 74 ++++++++
11 files changed, 524 insertions(+), 9 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent-runtime.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent-runtime.json
index 59172332101e..5c7b7d129daf 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent-runtime.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent-runtime.json
@@ -28,7 +28,7 @@
"knowledgeBaseId": { "index": 1, "kind": "property", "displayName":
"Knowledge Base Id", "group": "producer", "label": "", "required": true,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Define the Knowledge
Base Id we are going to use" },
"lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
"modelId": { "index": 3, "kind": "property", "displayName": "Model Id",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"java.lang.String", "enum": [ "anthropic.claude-instant-v1",
"anthropic.claude-v2", "anthropic.claude-v2:1" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configurat [...]
- "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"confi [...]
+ "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow", "retrieve" ], "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfigurat
[...]
"overrideEndpoint": { "index": 5, "kind": "property", "displayName":
"Override Endpoint", "group": "producer", "label": "", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Set the need for
overriding the endpoint. This option ne [...]
"pojoRequest": { "index": 6, "kind": "property", "displayName": "Pojo
Request", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If we want to use a
POJO request as body or not" },
"profileCredentialsName": { "index": 7, "kind": "property", "displayName":
"Profile Credentials Name", "group": "producer", "label": "", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "false",
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If using a profile
credentials pr [...]
@@ -63,13 +63,18 @@
"CamelAwsBedrockAgentRuntimeFlowExecutionId": { "index": 6, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "The unique identifier of
an in-progress flow execution to continue. Used for multi-turn flow
conversations.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConstants#FLOW_EXECU
[...]
"CamelAwsBedrockAgentRuntimeFlowOutputs": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowOutputEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow, this header will contain the list
of FlowOutputEvent emitted by the flow.", "constantName":
"org.apache.camel.componen [...]
"CamelAwsBedrockAgentRuntimeFlowTraces": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowTraceEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow with tracing enabled, this header
will contain the list of FlowTraceEvent emitted during execution.",
"constantName": "or [...]
- "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "When invoking a flow, this
header will contain the reason the flow completed (set when a
FlowCompletionEvent is received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntime [...]
+ "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "When invoking a flow, this
header will contain the reason the flow completed (set when a
FlowCompletionEvent is received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntime [...]
+ "CamelAwsBedrockAgentRuntimeRetrievedResults": { "index": 10, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When performing a retrieve operation, this header will
contain the list of KnowledgeBaseRetrievalResult chunks returned b [...]
+ "CamelAwsBedrockAgentRuntimeNumberOfResults": { "index": 11, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "Integer", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "Overrides the maximum
number of results returned by the retrieve operation. Must be a positive
Integer; when not set the AWS service default is used.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentrun [...]
+ "CamelAwsBedrockAgentRuntimeSearchType": { "index": 12, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the search type used by the
retrieve operation. Accepts the AWS SearchType enum (HYBRID, SEMANTIC) or its
String representation.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgent [...]
+ "CamelAwsBedrockAgentRuntimeNextToken": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Pagination token used by the retrieve
operation. Set on the in-message to request the next page; set on the
out-message when the response carries one.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.B [...]
+ "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction": { "index": 14,
"kind": "header", "displayName": "", "group": "producer", "label": "",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description":
"When performing a retrieve operation, this header will contain the guardrail
action (if any) applied by the knowledge base.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRu [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Logical name" },
"knowledgeBaseId": { "index": 1, "kind": "parameter", "displayName":
"Knowledge Base Id", "group": "producer", "label": "", "required": true,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Define the Knowledge
Base Id we are going to use" },
"modelId": { "index": 2, "kind": "parameter", "displayName": "Model Id",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"java.lang.String", "enum": [ "anthropic.claude-instant-v1",
"anthropic.claude-v2", "anthropic.claude-v2:1" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configura [...]
- "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"conf [...]
+ "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow", "retrieve" ], "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfigura
[...]
"overrideEndpoint": { "index": 4, "kind": "parameter", "displayName":
"Override Endpoint", "group": "producer", "label": "", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Set the need for
overriding the endpoint. This option n [...]
"pojoRequest": { "index": 5, "kind": "parameter", "displayName": "Pojo
Request", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If we want to use a
POJO request as body or not" },
"profileCredentialsName": { "index": 6, "kind": "parameter",
"displayName": "Profile Credentials Name", "group": "producer", "label": "",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"false", "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If using a profile
credentials p [...]
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json
index 4f4d6b8cdce1..210253329cb3 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-bedrock-agent.json
@@ -62,7 +62,12 @@
"CamelAwsBedrockAgentRuntimeFlowExecutionId": { "index": 6, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The unique identifier of an in-progress
flow execution to continue. Used for multi-turn flow conversations.",
"constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConstants#FLOW_EXECUTI
[...]
"CamelAwsBedrockAgentRuntimeFlowOutputs": { "index": 7, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowOutputEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow, this header will contain the list
of FlowOutputEvent emitted by the flow.", "constantName":
"org.apache.camel.component. [...]
"CamelAwsBedrockAgentRuntimeFlowTraces": { "index": 8, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowTraceEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow with tracing enabled, this header
will contain the list of FlowTraceEvent emitted during execution.",
"constantName": "org. [...]
- "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "When invoking a flow, this header will
contain the reason the flow completed (set when a FlowCompletionEvent is
received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeCo
[...]
+ "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "When invoking a flow, this header will
contain the reason the flow completed (set when a FlowCompletionEvent is
received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeCo
[...]
+ "CamelAwsBedrockAgentRuntimeRetrievedResults": { "index": 10, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When performing a retrieve operation, this header will
contain the list of KnowledgeBaseRetrievalResult chunks returned by [...]
+ "CamelAwsBedrockAgentRuntimeNumberOfResults": { "index": 11, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the maximum number of results
returned by the retrieve operation. Must be a positive Integer; when not set
the AWS service default is used.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentrunti [...]
+ "CamelAwsBedrockAgentRuntimeSearchType": { "index": 12, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the search type used by the
retrieve operation. Accepts the AWS SearchType enum (HYBRID, SEMANTIC) or its
String representation.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRu [...]
+ "CamelAwsBedrockAgentRuntimeNextToken": { "index": 13, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Pagination token used by the retrieve
operation. Set on the in-message to request the next page; set on the
out-message when the response carries one.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.Bed [...]
+ "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction": { "index": 14,
"kind": "header", "displayName": "", "group": "common", "label": "",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description":
"When performing a retrieve operation, this header will contain the guardrail
action (if any) applied by the knowledge base.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRunt [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"common", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration",
"configurationField": "configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json
b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json
index 4f4d6b8cdce1..210253329cb3 100644
---
a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json
+++
b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agent/aws-bedrock-agent.json
@@ -62,7 +62,12 @@
"CamelAwsBedrockAgentRuntimeFlowExecutionId": { "index": 6, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The unique identifier of an in-progress
flow execution to continue. Used for multi-turn flow conversations.",
"constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConstants#FLOW_EXECUTI
[...]
"CamelAwsBedrockAgentRuntimeFlowOutputs": { "index": 7, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowOutputEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow, this header will contain the list
of FlowOutputEvent emitted by the flow.", "constantName":
"org.apache.camel.component. [...]
"CamelAwsBedrockAgentRuntimeFlowTraces": { "index": 8, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowTraceEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow with tracing enabled, this header
will contain the list of FlowTraceEvent emitted during execution.",
"constantName": "org. [...]
- "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "When invoking a flow, this header will
contain the reason the flow completed (set when a FlowCompletionEvent is
received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeCo
[...]
+ "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "When invoking a flow, this header will
contain the reason the flow completed (set when a FlowCompletionEvent is
received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeCo
[...]
+ "CamelAwsBedrockAgentRuntimeRetrievedResults": { "index": 10, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When performing a retrieve operation, this header will
contain the list of KnowledgeBaseRetrievalResult chunks returned by [...]
+ "CamelAwsBedrockAgentRuntimeNumberOfResults": { "index": 11, "kind":
"header", "displayName": "", "group": "common", "label": "", "required": false,
"javaType": "Integer", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the maximum number of results
returned by the retrieve operation. Must be a positive Integer; when not set
the AWS service default is used.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentrunti [...]
+ "CamelAwsBedrockAgentRuntimeSearchType": { "index": 12, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the search type used by the
retrieve operation. Accepts the AWS SearchType enum (HYBRID, SEMANTIC) or its
String representation.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRu [...]
+ "CamelAwsBedrockAgentRuntimeNextToken": { "index": 13, "kind": "header",
"displayName": "", "group": "common", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Pagination token used by the retrieve
operation. Set on the in-message to request the next page; set on the
out-message when the response carries one.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.Bed [...]
+ "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction": { "index": 14,
"kind": "header", "displayName": "", "group": "common", "label": "",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description":
"When performing a retrieve operation, this header will contain the guardrail
action (if any) applied by the knowledge base.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRunt [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"common", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration",
"configurationField": "configuration", "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agentruntime/aws-bedrock-agent-runtime.json
b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agentruntime/aws-bedrock-agent-runtime.json
index 59172332101e..5c7b7d129daf 100644
---
a/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agentruntime/aws-bedrock-agent-runtime.json
+++
b/components/camel-aws/camel-aws-bedrock/src/generated/resources/META-INF/org/apache/camel/component/aws2/bedrock/agentruntime/aws-bedrock-agent-runtime.json
@@ -28,7 +28,7 @@
"knowledgeBaseId": { "index": 1, "kind": "property", "displayName":
"Knowledge Base Id", "group": "producer", "label": "", "required": true,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Define the Knowledge
Base Id we are going to use" },
"lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
"modelId": { "index": 3, "kind": "property", "displayName": "Model Id",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"java.lang.String", "enum": [ "anthropic.claude-instant-v1",
"anthropic.claude-v2", "anthropic.claude-v2:1" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configurat [...]
- "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"confi [...]
+ "operation": { "index": 4, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow", "retrieve" ], "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfigurat
[...]
"overrideEndpoint": { "index": 5, "kind": "property", "displayName":
"Override Endpoint", "group": "producer", "label": "", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Set the need for
overriding the endpoint. This option ne [...]
"pojoRequest": { "index": 6, "kind": "property", "displayName": "Pojo
Request", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If we want to use a
POJO request as body or not" },
"profileCredentialsName": { "index": 7, "kind": "property", "displayName":
"Profile Credentials Name", "group": "producer", "label": "", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "false",
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If using a profile
credentials pr [...]
@@ -63,13 +63,18 @@
"CamelAwsBedrockAgentRuntimeFlowExecutionId": { "index": 6, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "The unique identifier of
an in-progress flow execution to continue. Used for multi-turn flow
conversations.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConstants#FLOW_EXECU
[...]
"CamelAwsBedrockAgentRuntimeFlowOutputs": { "index": 7, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowOutputEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow, this header will contain the list
of FlowOutputEvent emitted by the flow.", "constantName":
"org.apache.camel.componen [...]
"CamelAwsBedrockAgentRuntimeFlowTraces": { "index": 8, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.FlowTraceEvent>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When invoking a flow with tracing enabled, this header
will contain the list of FlowTraceEvent emitted during execution.",
"constantName": "or [...]
- "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "When invoking a flow, this
header will contain the reason the flow completed (set when a
FlowCompletionEvent is received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntime [...]
+ "CamelAwsBedrockAgentRuntimeFlowCompletionReason": { "index": 9, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "When invoking a flow, this
header will contain the reason the flow completed (set when a
FlowCompletionEvent is received).", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntime [...]
+ "CamelAwsBedrockAgentRuntimeRetrievedResults": { "index": 10, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType":
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "When performing a retrieve operation, this header will
contain the list of KnowledgeBaseRetrievalResult chunks returned b [...]
+ "CamelAwsBedrockAgentRuntimeNumberOfResults": { "index": 11, "kind":
"header", "displayName": "", "group": "producer", "label": "", "required":
false, "javaType": "Integer", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "Overrides the maximum
number of results returned by the retrieve operation. Must be a positive
Integer; when not set the AWS service default is used.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentrun [...]
+ "CamelAwsBedrockAgentRuntimeSearchType": { "index": 12, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Overrides the search type used by the
retrieve operation. Accepts the AWS SearchType enum (HYBRID, SEMANTIC) or its
String representation.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgent [...]
+ "CamelAwsBedrockAgentRuntimeNextToken": { "index": 13, "kind": "header",
"displayName": "", "group": "producer", "label": "", "required": false,
"javaType": "String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Pagination token used by the retrieve
operation. Set on the in-message to request the next page; set on the
out-message when the response carries one.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.B [...]
+ "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction": { "index": 14,
"kind": "header", "displayName": "", "group": "producer", "label": "",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description":
"When performing a retrieve operation, this header will contain the guardrail
action (if any) applied by the knowledge base.", "constantName":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRu [...]
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Logical name" },
"knowledgeBaseId": { "index": 1, "kind": "parameter", "displayName":
"Knowledge Base Id", "group": "producer", "label": "", "required": true,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Define the Knowledge
Base Id we are going to use" },
"modelId": { "index": 2, "kind": "parameter", "displayName": "Model Id",
"group": "producer", "label": "", "required": true, "type": "enum", "javaType":
"java.lang.String", "enum": [ "anthropic.claude-instant-v1",
"anthropic.claude-v2", "anthropic.claude-v2:1" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configura [...]
- "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow" ], "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"conf [...]
+ "operation": { "index": 3, "kind": "parameter", "displayName":
"Operation", "group": "producer", "label": "", "required": true, "type":
"enum", "javaType":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeOperations",
"enum": [ "retrieveAndGenerate", "invokeFlow", "retrieve" ], "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfigura
[...]
"overrideEndpoint": { "index": 4, "kind": "parameter", "displayName":
"Override Endpoint", "group": "producer", "label": "", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "Set the need for
overriding the endpoint. This option n [...]
"pojoRequest": { "index": 5, "kind": "parameter", "displayName": "Pojo
Request", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If we want to use a
POJO request as body or not" },
"profileCredentialsName": { "index": 6, "kind": "parameter",
"displayName": "Profile Credentials Name", "group": "producer", "label": "",
"required": false, "type": "string", "javaType": "java.lang.String",
"deprecated": false, "autowired": false, "secret": false, "defaultValue":
"false", "configurationClass":
"org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration",
"configurationField": "configuration", "description": "If using a profile
credentials p [...]
diff --git
a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-runtime-component.adoc
b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-runtime-component.adoc
index 419b478e3496..95b39c95c22b 100644
---
a/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-runtime-component.adoc
+++
b/components/camel-aws/camel-aws-bedrock/src/main/docs/aws-bedrock-agent-runtime-component.adoc
@@ -56,8 +56,35 @@ the https://aws.amazon.com/bedrock/[Amazon Bedrock] service.
The component supports the following operations on the `operation` URI option:
* `retrieveAndGenerate` — Query a Bedrock Knowledge Base and generate a
grounded response from the selected model.
+* `retrieve` — Run a semantic search against a Bedrock Knowledge Base and
return the matched chunks without LLM generation.
* `invokeFlow` — Invoke a Bedrock Flow by id/alias and stream the resulting
events back as Camel message headers.
+=== Retrieving from a Bedrock Knowledge Base
+
+The `retrieve` operation performs a semantic search against a Bedrock
Knowledge Base and returns the matching chunks
+without invoking an LLM. Use this when you want to plug retrieval into your
own generation step, inspect retrieval
+quality, or build pagination on top of the knowledge base.
+
+Mandatory options:
+
+* `knowledgeBaseId` — the id of the Bedrock Knowledge Base to query.
+
+The body of the in-message must be a `String` containing the search query.
When `pojoRequest=true`, the body must be a
+`RetrieveRequest` (any retrieval-config knobs in that POJO are honored
verbatim).
+
+The retrieval configuration can be tuned per exchange via the following
headers:
+
+* `CamelAwsBedrockAgentRuntimeNumberOfResults` (Integer) — maximum number of
chunks to return.
+* `CamelAwsBedrockAgentRuntimeSearchType` (String) — overrides the search type
(`HYBRID` or `SEMANTIC`).
+* `CamelAwsBedrockAgentRuntimeNextToken` (String) — pagination token returned
by a previous call.
+
+The producer surfaces the matched chunks as the out-message body (a
`List<KnowledgeBaseRetrievalResult>`) and on the
+following headers:
+
+* `CamelAwsBedrockAgentRuntimeRetrievedResults` — the same
`List<KnowledgeBaseRetrievalResult>` available on the body.
+* `CamelAwsBedrockAgentRuntimeNextToken` — present when the response carries a
pagination token.
+* `CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction` — present when the
knowledge base applies a guardrail action.
+
=== Invoking a Bedrock Flow
The `invokeFlow` operation streams flow events using the AWS SDK async client;
the producer transparently allocates a
diff --git
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConstants.java
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConstants.java
index f7a8549b91ea..359934baaa20 100644
---
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConstants.java
+++
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeConstants.java
@@ -62,4 +62,29 @@ public interface BedrockAgentRuntimeConstants {
@Metadata(description = "When invoking a flow, this header will contain
the reason the flow completed (set when a FlowCompletionEvent is received).",
javaType = "String")
String FLOW_COMPLETION_REASON =
"CamelAwsBedrockAgentRuntimeFlowCompletionReason";
+
+ @Metadata(description = "When performing a retrieve operation, this header
will contain the list of "
+ + "KnowledgeBaseRetrievalResult chunks returned by
the knowledge base.",
+ javaType =
"java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>")
+ String RETRIEVED_RESULTS = "CamelAwsBedrockAgentRuntimeRetrievedResults";
+
+ @Metadata(description = "Overrides the maximum number of results returned
by the retrieve operation. "
+ + "Must be a positive Integer; when not set the
AWS service default is used.",
+ javaType = "Integer")
+ String NUMBER_OF_RESULTS = "CamelAwsBedrockAgentRuntimeNumberOfResults";
+
+ @Metadata(description = "Overrides the search type used by the retrieve
operation. Accepts the AWS SearchType "
+ + "enum (HYBRID, SEMANTIC) or its String
representation.",
+ javaType = "String")
+ String OVERRIDE_SEARCH_TYPE = "CamelAwsBedrockAgentRuntimeSearchType";
+
+ @Metadata(description = "Pagination token used by the retrieve operation.
Set on the in-message to request "
+ + "the next page; set on the out-message when the
response carries one.",
+ javaType = "String")
+ String NEXT_TOKEN = "CamelAwsBedrockAgentRuntimeNextToken";
+
+ @Metadata(description = "When performing a retrieve operation, this header
will contain the guardrail action "
+ + "(if any) applied by the knowledge base.",
+ javaType = "String")
+ String RETRIEVE_GUARDRAIL_ACTION =
"CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction";
}
diff --git
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeOperations.java
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeOperations.java
index 25e63ce796b3..785ae1f74c66 100644
---
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeOperations.java
+++
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeOperations.java
@@ -19,5 +19,6 @@ package org.apache.camel.component.aws2.bedrock.agentruntime;
public enum BedrockAgentRuntimeOperations {
retrieveAndGenerate,
- invokeFlow
+ invokeFlow,
+ retrieve
}
diff --git
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java
index 0a096d2fc596..5eb27f4d1490 100644
---
a/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java
+++
b/components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java
@@ -40,7 +40,9 @@ import
software.amazon.awssdk.services.bedrockagentruntime.model.FlowOutputEvent
import
software.amazon.awssdk.services.bedrockagentruntime.model.FlowTraceEvent;
import
software.amazon.awssdk.services.bedrockagentruntime.model.InvokeFlowRequest;
import
software.amazon.awssdk.services.bedrockagentruntime.model.InvokeFlowResponseHandler;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseQuery;
import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalConfiguration;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult;
import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrieveAndGenerateConfiguration;
import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseVectorSearchConfiguration;
import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveAndGenerateConfiguration;
@@ -48,6 +50,8 @@ import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveAndGene
import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveAndGenerateRequest;
import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveAndGenerateResponse;
import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveAndGenerateType;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse;
/**
* A Producer which sends messages to the Amazon Bedrock Agent Runtime Service
@@ -71,6 +75,9 @@ public class BedrockAgentRuntimeProducer extends
DefaultProducer {
case invokeFlow:
invokeFlow(exchange);
break;
+ case retrieve:
+ retrieve(getEndpoint().getBedrockAgentRuntimeClient(),
exchange);
+ break;
default:
throw new IllegalArgumentException("Unsupported operation");
}
@@ -166,6 +173,83 @@ public class BedrockAgentRuntimeProducer extends
DefaultProducer {
message.setBody(result.output().text());
}
+ private void retrieve(BedrockAgentRuntimeClient bedrockAgentRuntimeClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ RetrieveRequest request;
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getMessage().getMandatoryBody();
+ if (payload instanceof RetrieveRequest retrieveRequest) {
+ request = retrieveRequest;
+ } else {
+ throw new IllegalArgumentException(
+ "retrieve operation requires a RetrieveRequest body
when pojoRequest=true");
+ }
+ } else {
+ request = buildRetrieveRequest(exchange);
+ }
+
+ RetrieveResponse response;
+ try {
+ response = bedrockAgentRuntimeClient.retrieve(request);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Retrieve command returned the error code {}",
ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+
+ Message message = getMessageForResponse(exchange);
+ prepareRetrieveResponse(response, message);
+ }
+
+ private RetrieveRequest buildRetrieveRequest(Exchange exchange) throws
InvalidPayloadException {
+ String knowledgeBaseId = getConfiguration().getKnowledgeBaseId();
+ if (ObjectHelper.isEmpty(knowledgeBaseId)) {
+ throw new IllegalArgumentException("retrieve operation requires
knowledgeBaseId in the endpoint configuration");
+ }
+
+ String queryText =
exchange.getMessage().getMandatoryBody(String.class);
+
+ KnowledgeBaseVectorSearchConfiguration.Builder vectorSearchBuilder =
KnowledgeBaseVectorSearchConfiguration.builder();
+ Integer numberOfResults
+ =
exchange.getMessage().getHeader(BedrockAgentRuntimeConstants.NUMBER_OF_RESULTS,
Integer.class);
+ if (numberOfResults != null) {
+ vectorSearchBuilder.numberOfResults(numberOfResults);
+ }
+ String overrideSearchType
+ =
exchange.getMessage().getHeader(BedrockAgentRuntimeConstants.OVERRIDE_SEARCH_TYPE,
String.class);
+ if (ObjectHelper.isNotEmpty(overrideSearchType)) {
+ vectorSearchBuilder.overrideSearchType(overrideSearchType);
+ }
+
+ KnowledgeBaseRetrievalConfiguration retrievalConfiguration =
KnowledgeBaseRetrievalConfiguration.builder()
+ .vectorSearchConfiguration(vectorSearchBuilder.build())
+ .build();
+
+ RetrieveRequest.Builder builder = RetrieveRequest.builder()
+ .knowledgeBaseId(knowledgeBaseId)
+
.retrievalQuery(KnowledgeBaseQuery.builder().text(queryText).build())
+ .retrievalConfiguration(retrievalConfiguration);
+
+ String nextToken =
exchange.getMessage().getHeader(BedrockAgentRuntimeConstants.NEXT_TOKEN,
String.class);
+ if (ObjectHelper.isNotEmpty(nextToken)) {
+ builder.nextToken(nextToken);
+ }
+
+ return builder.build();
+ }
+
+ private void prepareRetrieveResponse(RetrieveResponse response, Message
message) {
+ List<KnowledgeBaseRetrievalResult> results
+ = response.hasRetrievalResults() ? response.retrievalResults()
: Collections.emptyList();
+ message.setHeader(BedrockAgentRuntimeConstants.RETRIEVED_RESULTS,
results);
+ if (ObjectHelper.isNotEmpty(response.nextToken())) {
+ message.setHeader(BedrockAgentRuntimeConstants.NEXT_TOKEN,
response.nextToken());
+ }
+ if (ObjectHelper.isNotEmpty(response.guardrailActionAsString())) {
+
message.setHeader(BedrockAgentRuntimeConstants.RETRIEVE_GUARDRAIL_ACTION,
response.guardrailActionAsString());
+ }
+ message.setBody(results);
+ }
+
private void invokeFlow(Exchange exchange) throws InvalidPayloadException {
BedrockAgentRuntimeAsyncClient asyncClient =
getEndpoint().getBedrockAgentRuntimeAsyncClient();
if (asyncClient == null) {
diff --git
a/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducerRetrieveTest.java
b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducerRetrieveTest.java
new file mode 100644
index 000000000000..fe6a98447484
--- /dev/null
+++
b/components/camel-aws/camel-aws-bedrock/src/test/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducerRetrieveTest.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.aws2.bedrock.agentruntime;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.SimpleRegistry;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import
software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrievalResultContent;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest;
+import
software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse;
+import software.amazon.awssdk.services.bedrockagentruntime.model.SearchType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.lenient;
+
+@ExtendWith(MockitoExtension.class)
+public class BedrockAgentRuntimeProducerRetrieveTest {
+
+ @Mock
+ private BedrockAgentRuntimeClient syncClient;
+
+ private CamelContext camelContext;
+ private ProducerTemplate template;
+ private AtomicReference<RetrieveRequest> capturedRequest;
+
+ @BeforeEach
+ public void setup() throws Exception {
+ capturedRequest = new AtomicReference<>();
+ // Capture the request, return a small synthetic response so the
producer's response-handling path is also
+ // exercised (results in body + RETRIEVED_RESULTS header, optional
nextToken header). lenient(): one of the
+ // tests verifies a producer-side validation that throws before
reaching the client.
+ lenient().doAnswer(invocation -> {
+ capturedRequest.set(invocation.getArgument(0,
RetrieveRequest.class));
+ KnowledgeBaseRetrievalResult result =
KnowledgeBaseRetrievalResult.builder()
+ .content(RetrievalResultContent.builder().text("matched
chunk").build())
+ .score(0.87)
+ .build();
+ return RetrieveResponse.builder()
+ .retrievalResults(result)
+ .nextToken("page-2-token")
+ .build();
+ }).when(syncClient).retrieve(any(RetrieveRequest.class));
+
+ SimpleRegistry registry = new SimpleRegistry();
+ registry.bind("syncClient", syncClient);
+ camelContext = new DefaultCamelContext(registry);
+ camelContext.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:retrieve")
+ .to("aws-bedrock-agent-runtime://label"
+ + "?bedrockAgentRuntimeClient=#syncClient"
+ + "&operation=retrieve"
+ + "&knowledgeBaseId=kb-1"
+ + "®ion=us-east-1"
+ + "&accessKey=unused"
+ + "&secretKey=unused");
+
+ from("direct:retrieve-no-kb")
+ .to("aws-bedrock-agent-runtime://label2"
+ + "?bedrockAgentRuntimeClient=#syncClient"
+ + "&operation=retrieve"
+ + "®ion=us-east-1"
+ + "&accessKey=unused"
+ + "&secretKey=unused");
+
+ from("direct:retrieve-pojo")
+ .to("aws-bedrock-agent-runtime://label3"
+ + "?bedrockAgentRuntimeClient=#syncClient"
+ + "&operation=retrieve"
+ + "&knowledgeBaseId=kb-1"
+ + "&pojoRequest=true"
+ + "®ion=us-east-1"
+ + "&accessKey=unused"
+ + "&secretKey=unused");
+ }
+ });
+ camelContext.start();
+ template = camelContext.createProducerTemplate();
+ }
+
+ @AfterEach
+ public void teardown() {
+ if (template != null) {
+ template.stop();
+ }
+ if (camelContext != null) {
+ camelContext.stop();
+ }
+ }
+
+ @Test
+ public void retrieveBuildsRequestFromStringBodyAndEndpointConfig() {
+ Exchange result = template.send("direct:retrieve",
+ exchange -> exchange.getMessage().setBody("what is camel?"));
+
+ assertNull(result.getException(), "Exchange should not fail");
+ RetrieveRequest request = capturedRequest.get();
+ assertNotNull(request, "Producer must have invoked the sync client");
+ assertEquals("kb-1", request.knowledgeBaseId());
+ assertNotNull(request.retrievalQuery(), "Retrieval query must be
populated");
+ assertEquals("what is camel?", request.retrievalQuery().text());
+ // Default knobs (no headers): vector search config is built but no
numberOfResults / overrideSearchType set.
+ assertNotNull(request.retrievalConfiguration(), "Retrieval
configuration must be populated");
+
assertNotNull(request.retrievalConfiguration().vectorSearchConfiguration(),
+ "Vector search configuration must be populated");
+
assertNull(request.retrievalConfiguration().vectorSearchConfiguration().numberOfResults(),
+ "numberOfResults must not be set when no header is present");
+
assertNull(request.retrievalConfiguration().vectorSearchConfiguration().overrideSearchType(),
+ "overrideSearchType must not be set when no header is
present");
+ assertNull(request.nextToken(), "nextToken must not be set when no
header is present");
+
+ // Response should surface results both in body and in a dedicated
header.
+ Object body = result.getMessage().getBody();
+ assertInstanceOf(List.class, body);
+ List<?> bodyList = (List<?>) body;
+ assertEquals(1, bodyList.size());
+ assertInstanceOf(KnowledgeBaseRetrievalResult.class, bodyList.get(0));
+ assertEquals("matched chunk", ((KnowledgeBaseRetrievalResult)
bodyList.get(0)).content().text());
+
+ Object header =
result.getMessage().getHeader(BedrockAgentRuntimeConstants.RETRIEVED_RESULTS);
+ assertInstanceOf(List.class, header);
+ assertEquals(1, ((List<?>) header).size());
+ assertSame(body, header, "Header and body should reference the same
result list");
+
+ assertEquals("page-2-token",
result.getMessage().getHeader(BedrockAgentRuntimeConstants.NEXT_TOKEN));
+ }
+
+ @Test
+ public void retrieveAppliesRetrievalConfigHeaders() {
+ template.send("direct:retrieve", exchange -> {
+
exchange.getMessage().setHeader(BedrockAgentRuntimeConstants.NUMBER_OF_RESULTS,
7);
+
exchange.getMessage().setHeader(BedrockAgentRuntimeConstants.OVERRIDE_SEARCH_TYPE,
"HYBRID");
+
exchange.getMessage().setHeader(BedrockAgentRuntimeConstants.NEXT_TOKEN,
"page-1-token");
+ exchange.getMessage().setBody("hello");
+ });
+
+ RetrieveRequest request = capturedRequest.get();
+ assertNotNull(request);
+ assertEquals(Integer.valueOf(7),
+
request.retrievalConfiguration().vectorSearchConfiguration().numberOfResults(),
+ "Header CamelAwsBedrockAgentRuntimeNumberOfResults must
populate numberOfResults");
+ assertEquals(SearchType.HYBRID,
+
request.retrievalConfiguration().vectorSearchConfiguration().overrideSearchType(),
+ "Header CamelAwsBedrockAgentRuntimeSearchType must populate
overrideSearchType");
+ assertEquals("page-1-token", request.nextToken(),
+ "Header CamelAwsBedrockAgentRuntimeNextToken must populate
nextToken");
+ }
+
+ @Test
+ public void retrieveFailsWhenKnowledgeBaseIdIsMissing() {
+ CamelExecutionException ex =
assertThrows(CamelExecutionException.class,
+ () -> template.sendBody("direct:retrieve-no-kb", "hi"));
+ Throwable cause = ex.getCause();
+ assertInstanceOf(IllegalArgumentException.class, cause);
+ assertEquals("retrieve operation requires knowledgeBaseId in the
endpoint configuration", cause.getMessage());
+ }
+
+ @Test
+ public void retrieveUsesPojoRequestBodyVerbatim() {
+ RetrieveRequest pojo = RetrieveRequest.builder()
+ .knowledgeBaseId("kb-from-pojo")
+ .retrievalQuery(q -> q.text("pojo question"))
+ .build();
+
+ Exchange result = template.send("direct:retrieve-pojo", exchange ->
exchange.getMessage().setBody(pojo));
+
+ assertNull(result.getException());
+ RetrieveRequest sent = capturedRequest.get();
+ assertNotNull(sent);
+ // Verify the producer forwarded the POJO without rebuilding it from
endpoint config.
+ assertSame(pojo, sent,
+ "When pojoRequest=true, the RetrieveRequest provided in the
body must be sent to the client unchanged");
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java
index 90d371aa4a92..66d9a5c52e29 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentEndpointBuilderFactory.java
@@ -2415,6 +2415,80 @@ public interface BedrockAgentEndpointBuilderFactory {
public String awsBedrockAgentRuntimeFlowCompletionReason() {
return "CamelAwsBedrockAgentRuntimeFlowCompletionReason";
}
+ /**
+ * When performing a retrieve operation, this header will contain the
+ * list of KnowledgeBaseRetrievalResult chunks returned by the
knowledge
+ * base.
+ *
+ * The option is a: {@code
+ *
java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>}
type.
+ *
+ * Group: common
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeRetrievedResults}.
+ */
+ public String awsBedrockAgentRuntimeRetrievedResults() {
+ return "CamelAwsBedrockAgentRuntimeRetrievedResults";
+ }
+ /**
+ * Overrides the maximum number of results returned by the retrieve
+ * operation. Must be a positive Integer; when not set the AWS service
+ * default is used.
+ *
+ * The option is a: {@code Integer} type.
+ *
+ * Group: common
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeNumberOfResults}.
+ */
+ public String awsBedrockAgentRuntimeNumberOfResults() {
+ return "CamelAwsBedrockAgentRuntimeNumberOfResults";
+ }
+ /**
+ * Overrides the search type used by the retrieve operation. Accepts
the
+ * AWS SearchType enum (HYBRID, SEMANTIC) or its String representation.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: common
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeSearchType}.
+ */
+ public String awsBedrockAgentRuntimeSearchType() {
+ return "CamelAwsBedrockAgentRuntimeSearchType";
+ }
+ /**
+ * Pagination token used by the retrieve operation. Set on the
+ * in-message to request the next page; set on the out-message when the
+ * response carries one.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: common
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeNextToken}.
+ */
+ public String awsBedrockAgentRuntimeNextToken() {
+ return "CamelAwsBedrockAgentRuntimeNextToken";
+ }
+ /**
+ * When performing a retrieve operation, this header will contain the
+ * guardrail action (if any) applied by the knowledge base.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: common
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeRetrieveGuardrailAction}.
+ */
+ public String awsBedrockAgentRuntimeRetrieveGuardrailAction() {
+ return "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction";
+ }
}
static BedrockAgentEndpointBuilder endpointBuilder(String componentName,
String path) {
class BedrockAgentEndpointBuilderImpl extends AbstractEndpointBuilder
implements BedrockAgentEndpointBuilder, AdvancedBedrockAgentEndpointBuilder {
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentRuntimeEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentRuntimeEndpointBuilderFactory.java
index 8a2f24af9eac..afe08e69eee5 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentRuntimeEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BedrockAgentRuntimeEndpointBuilderFactory.java
@@ -867,6 +867,80 @@ public interface BedrockAgentRuntimeEndpointBuilderFactory
{
public String awsBedrockAgentRuntimeFlowCompletionReason() {
return "CamelAwsBedrockAgentRuntimeFlowCompletionReason";
}
+ /**
+ * When performing a retrieve operation, this header will contain the
+ * list of KnowledgeBaseRetrievalResult chunks returned by the
knowledge
+ * base.
+ *
+ * The option is a: {@code
+ *
java.util.List<software.amazon.awssdk.services.bedrockagentruntime.model.KnowledgeBaseRetrievalResult>}
type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeRetrievedResults}.
+ */
+ public String awsBedrockAgentRuntimeRetrievedResults() {
+ return "CamelAwsBedrockAgentRuntimeRetrievedResults";
+ }
+ /**
+ * Overrides the maximum number of results returned by the retrieve
+ * operation. Must be a positive Integer; when not set the AWS service
+ * default is used.
+ *
+ * The option is a: {@code Integer} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeNumberOfResults}.
+ */
+ public String awsBedrockAgentRuntimeNumberOfResults() {
+ return "CamelAwsBedrockAgentRuntimeNumberOfResults";
+ }
+ /**
+ * Overrides the search type used by the retrieve operation. Accepts
the
+ * AWS SearchType enum (HYBRID, SEMANTIC) or its String representation.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeSearchType}.
+ */
+ public String awsBedrockAgentRuntimeSearchType() {
+ return "CamelAwsBedrockAgentRuntimeSearchType";
+ }
+ /**
+ * Pagination token used by the retrieve operation. Set on the
+ * in-message to request the next page; set on the out-message when the
+ * response carries one.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeNextToken}.
+ */
+ public String awsBedrockAgentRuntimeNextToken() {
+ return "CamelAwsBedrockAgentRuntimeNextToken";
+ }
+ /**
+ * When performing a retrieve operation, this header will contain the
+ * guardrail action (if any) applied by the knowledge base.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code
+ * AwsBedrockAgentRuntimeRetrieveGuardrailAction}.
+ */
+ public String awsBedrockAgentRuntimeRetrieveGuardrailAction() {
+ return "CamelAwsBedrockAgentRuntimeRetrieveGuardrailAction";
+ }
}
static BedrockAgentRuntimeEndpointBuilder endpointBuilder(String
componentName, String path) {
class BedrockAgentRuntimeEndpointBuilderImpl extends
AbstractEndpointBuilder implements BedrockAgentRuntimeEndpointBuilder,
AdvancedBedrockAgentRuntimeEndpointBuilder {