Andrea Cosentino created CAMEL-24224:
----------------------------------------
Summary: camel-aws-bedrock: streaming metadata never captured for
Claude/Nova, and inference profile ids rejected
Key: CAMEL-24224
URL: https://issues.apache.org/jira/browse/CAMEL-24224
Project: Camel
Issue Type: Bug
Components: camel-aws
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.22.0, 4.18.4
Two defects in the Bedrock runtime producer:
1. *Streaming metadata is never captured for Claude and Nova.*
BedrockStreamHandler extracts the completion reason and token count only when
parser.isFinalChunk(chunk) is true. For Claude (and Nova, which reuses
ClaudeStreamParser) isFinalChunk matches the message_stop chunk, but
stop_reason and usage are reported on the earlier message_delta chunk. A chunk
is never both, so the CamelAwsBedrockStreamingCompletionReason and token-count
values are always absent for those model families. Titan/Llama/Mistral/Cohere
are unaffected because they report metadata on their final chunk. The parsers
themselves are correct (ClaudeStreamParserTest already asserts extraction from
a message_delta chunk) - only the handler's gating is wrong.
2. *Cross-region inference profile ids and ARNs are rejected.* setResponseText
switches on the exact configured modelId with a throwing default. Bedrock also
accepts cross-region inference profile ids (us./eu./apac./us-gov. prefixed,
e.g. us.anthropic.claude-3-5-sonnet-20241022-v2:0) and inference-profile ARNs,
which address the same foundation model. Those, and any model released after
the hard-coded list was written, fail with "Unexpected model: ..." even though
the response format is determined by the model family.
Fix: inspect every streaming chunk for metadata instead of gating on the final
chunk, resolve the underlying foundation-model id (stripping an
inference-profile region prefix or ARN path) before the switch, and fall back
to family-prefix dispatch for ids that are not listed explicitly while still
rejecting non-text families.
Code references (main): BedrockStreamHandler.java (both onChunk blocks),
BedrockProducer.setResponseText.
Found during an agent-assisted audit of the AWS components.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)