oscerd opened a new pull request, #25086:
URL: https://github.com/apache/camel/pull/25086

   ### Motivation
   
   [CAMEL-23467](https://issues.apache.org/jira/browse/CAMEL-23467). The 
`aws-bedrock-agent-runtime` component did not expose **InvokeAgent** (invoking 
a deployed Bedrock agent) or **InvokeInlineAgent** (defining the agent at 
invocation time) — the primary entry points for agent-based workflows on 
Bedrock.
   
   ### Approach
   
   Both APIs return event-stream responses, and the component already had a 
working precedent for that in `invokeFlow`: the AWS SDK **async** client, a 
response handler whose visitor collects the emitted events, awaited with 
`join()` and unwrapping the `CompletionException` that wraps AWS service 
exceptions. Both new operations follow that same shape rather than introducing 
parallel machinery.
   
   ### Changes
   
   - **Operations**: `invokeAgent` and `invokeInlineAgent` added to 
`BedrockAgentRuntimeOperations` and wired into the producer.
   - **Options** (each overridable by header): `agentId`, `agentAliasId`, 
`sessionId`, `streamOutputMode`, and for the inline variant `foundationModel` / 
`instruction`. `enableTrace` is reused and its label/doc widened to cover 
agents.
   - **Async client**: provisioned for the two new operations, exactly as for 
`invokeFlow` (so users don't pay for a Netty client when only doing synchronous 
operations).
   - **Event handling**: all four `ResponseStream` events (`chunk`, `trace`, 
`returnControl`, `files`) are collected. Traces, return-control payloads, files 
and citations are published as headers. Citations arrive on the **chunk 
attribution** rather than as their own event, which is where they're picked up.
   - **`streamOutputMode`**: honored with the same semantics as the runtime 
component — `complete` (default) accumulates the chunks into a `String` body, 
`chunks` exposes the `List<String>`. Overridable per exchange by header.
   - **Sessions**: the agent APIs are session-based, so a session id is 
generated when neither config nor header supplies one, and the id actually used 
is always echoed back on `CamelAwsBedrockAgentRuntimeSessionId` so a route can 
continue the conversation.
   - **POJO mode**: `pojoRequest=true` accepts an `InvokeAgentRequest` / 
`InvokeInlineAgentRequest` unchanged — which is also how the richer inline 
options (action groups, knowledge bases, collaborators, guardrails) are 
reachable without adding a dozen URI options.
   - **Docs**: three new sections in `aws-bedrock-agent-runtime-component.adoc` 
plus the supported-operations list.
   
   One thing worth flagging for review: `invokeAgent` and `invokeInlineAgent` 
use **parallel but distinct** SDK type families (`PayloadPart`/`TracePart`/… vs 
`InlineAgentPayloadPart`/`InlineAgentTracePart`/…). The collected 
traces/return-controls/files are therefore held as the SDK objects and the 
header metadata documents both variants, rather than pretending a single type 
applies.
   
   ### Testing
   
   `BedrockAgentRuntimeProducerInvokeAgentTest` — **9 tests, all passing** — 
mirroring the existing `invokeFlow` test approach (mocked async client 
capturing the request):
   
   - request built from string body + endpoint config, for both operations
   - header overrides for agent id/alias/session/trace/endSession/memoryId, and 
for inline model/instruction
   - session id generated when not configured, and echoed back on the response
   - missing `agentId` / `foundationModel` produce a clear validation error
   - `streamOutputMode` branching shapes the body (`String` vs `List`), 
including the header override
   
   Full reactor `mvn clean install -DskipTests` from root: success, with 
catalog/DSL metadata regenerated.
   
   *Note on the regenerated `aws-bedrock-agent` metadata:* that component 
declares `headersClass = BedrockAgentRuntimeConstants.class` (pre-existing), so 
adding constants there also regenerates its header metadata. I verified this is 
index renumbering plus the new entries — all existing `Flow*` headers remain 
present (15 → 26 headers, none removed).
   
   Main-only (4.22.0), additive — no backport.
   
   _Claude Code on behalf of Andrea Cosentino (@oscerd)._
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to