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

   Fixes [CAMEL-26071](https://issues.apache.org/jira/browse/CAMEL-26071).
   
   Only the agent-runtime part of camel-aws-bedrock is touched. It does not 
overlap with the files of #28892 (CAMEL-26069, runtime producer).
   
   ## 1. invokeFlow did not convert the body
   
   **Was:** `buildFlowInputs` took a String, a `FlowInput` or a 
`List<FlowInput>` and failed for anything else, so a byte[], an InputStream or 
a file from a file consumer gave `IllegalArgumentException: invokeFlow expects 
the body to be ... Got: [B`.
   
   **Now:** another body is converted to a String with the type converter (the 
same `resolveInputText` that invokeAgent and invokeInlineAgent use) and becomes 
the document of `FlowInputNode`. A `FlowInput` and a `List<FlowInput>` work as 
before; a List of something else still fails. The catalog body types 
(`producerIn`, invokeFlow) and the component doc are updated.
   
   ## 2. An operation picked by the header failed on an endpoint of another 
operation
   
   **Was:** the async client was only built in `doStart` when the `operation` 
option was invokeFlow, invokeAgent or invokeInlineAgent. The 
`CamelAwsBedrockAgentRuntimeOperation` header picking one of them on a retrieve 
or retrieveAndGenerate endpoint failed every exchange with 
`IllegalStateException: BedrockAgentRuntimeAsyncClient is not available`.
   
   **Now:** new 
`BedrockAgentRuntimeEndpoint.getOrCreateBedrockAgentRuntimeAsyncClient()` 
creates the async client on first use (double-checked under a lock) and the 
producer uses it. `doStart` still builds it eagerly only for these operations, 
so an endpoint of a sync operation still gets no Netty client unless an 
exchange needs one (the deliberate choice in the existing code is kept). 
`doStop` closes it as before and clears the field, so a restart does not reuse 
a closed client. `getBedrockAgentRuntimeAsyncClient()` is unchanged.
   
   ## 3. No operation failed with a NullPointerException
   
   **Now:** `IllegalArgumentException: Operation must be specified with the 
operation option or the CamelAwsBedrockAgentRuntimeOperation header` (the same 
wording as #28892 uses for aws-bedrock).
   
   ## Also from the issue
   
   - `modelId` and `knowledgeBaseId` are no longer `required = true`: only 
retrieve and retrieveAndGenerate use them. Their descriptions now say which 
operation uses them. retrieve already fails with a clear message without 
`knowledgeBaseId`.
   - `CamelAwsBedrockAgentRuntimeCitations` is documented as 
`java.util.List<...model.Citation>` (was `String`).
   - The doc page named `bedrockRuntimeClient`; it is 
`bedrockAgentRuntimeClient`.
   
   ## Tests
   
   - `BedrockAgentRuntimeProducerInvokeFlowTest`: byte[] and InputStream bodies 
become the flow input document.
   - New `BedrockAgentRuntimeProducerOperationTest`: no operation fails with 
the message; the header picks invokeFlow and then invokeAgent on a retrieve 
endpoint (factory mocked with `mockStatic`), and the async client is created 
once.
   - `BedrockAgentRuntimeEndpointTest`: a retrieve endpoint creates the async 
client on first use, reuses it, closes it on stop and clears it.
   
   The 4 new producer tests failed before the fix (checked by stashing the main 
code); the endpoint test uses the new method. Module: 152 tests, 0 failures 
(`mvn clean install -Psourcecheck`).
   
   ## Generated files
   
   Regenerated the component JSON, copied it and the doc into `camel-catalog`, 
and regenerated `camel-endpointdsl` and `camel-componentdsl`. No upgrade-guide 
entry: every change turns a failure into working behaviour, or only changes 
tooling metadata.
   
   ## Not changed
   
   - A `Map` or POJO body for invokeFlow is sent as its `toString()`, like for 
the other operations of this component. Turning a Map into a `Document` object 
for an input node of type Object would be a new feature, not part of this issue.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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