davsclaus opened a new pull request, #24347: URL: https://github.com/apache/camel/pull/24347
## Summary - Add token usage (input/output/total token count) and finish reason as exchange headers to the `camel-langchain4j-chat` and `camel-langchain4j-tools` producers, matching the pattern already established in `camel-langchain4j-embeddings` - For the tools producer, token usage is accumulated across the tool-calling loop iterations so the headers reflect the total cost of the entire agentic interaction - The `camel-langchain4j-agent` component is deferred to a follow-up issue as it requires an API change to the `Agent.chat()` return type ### Changes **camel-langchain4j-chat:** - `LangChain4jChatHeaders` — added `FINISH_REASON`, `INPUT_TOKEN_COUNT`, `OUTPUT_TOKEN_COUNT`, `TOTAL_TOKEN_COUNT` constants - `LangChain4jChatProducer` — captures `ChatResponse` instead of discarding it via `.aiMessage()`, sets token usage/finish reason headers **camel-langchain4j-tools:** - `LangChain4jToolsHeaders` — new headers class with the same four constants - `LangChain4jToolsEndpoint` — added `headersClass` reference - `LangChain4jToolsProducer` — changed `chatWithLLM()` to return `ChatResponse`; `toolsChat()` accumulates token usage across loop iterations and sets headers on the final response ## Test plan - [x] `camel-langchain4j-chat` module builds and tests pass - [x] `camel-langchain4j-tools` module builds and tests pass - [x] Catalog, endpoint-dsl, and component-dsl regenerated successfully - [ ] Manual verification with a real LLM to confirm headers are populated _Claude Code on behalf of Claus Ibsen_ Co-Authored-By: Claude Opus 4.6 <[email protected]> -- 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]
