Andrea Cosentino created CAMEL-26584:
----------------------------------------
Summary: camel-aws-bedrock - clear the retrieve token on the last
page
Key: CAMEL-26584
URL: https://issues.apache.org/jira/browse/CAMEL-26584
Project: Camel
Issue Type: Bug
Components: camel-aws2
Reporter: Andrea Cosentino
`components/camel-aws/camel-aws-bedrock/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/BedrockAgentRuntimeProducer.java:273`
```java
if (ObjectHelper.isNotEmpty(response.nextToken())) {
message.setHeader(BedrockAgentRuntimeConstants.NEXT_TOKEN,
response.nextToken());
}
```
The request reads the same header at 261; getMessageForResponse returns the
existing exchange message at 681. When a request supplies a token and the final
response omits it, the old token remains. Routes that loop while the header
exists can fetch the final page repeatedly. Remove the header on a terminal
response. Tests cover input and output tokens separately, not the terminal
transition.
History: unchanged token handling since CAMEL-23466 / 5cc87cb60862.
[AWS Retrieve
contract](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Retrieve.html)
defines a returned token for additional results.
Expected behavior: the operation honors its documented contract, including
exceptional and terminal paths. Add regression tests for the triggering case
described above.
Audited against upstream main 3658e02a7f9d. AI-generated by Codex on behalf of
oscerd (JIRA acosentino).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)