atiaomar1978-hub opened a new pull request, #24917: URL: https://github.com/apache/camel/pull/24917
**Branch:** `CAMEL-23951-agent-sources-tool-headers` **Commit:** `f09c3fd4dc17` **PR link:** https://github.com/atiaomar1978-hub/camel/pull/new/CAMEL-23951-agent-sources-tool-headers --- ## Summary (for PR description) ### CAMEL-23951: Expose agent `Result.sources()` and `Result.toolExecutions()` as message headers The langchain4j-agent producer already mapped `Result.content()`, finish reason, and token usage to exchange headers (CAMEL-23860). RAG sources and tool execution details from the LangChain4j `Result` were dropped, which limited observability, auditing, and downstream routing. This change adds two new output headers, following the same null/empty guard pattern as the existing metadata headers: | Header | Type | When set | |--------|------|----------| | `CamelLangChain4jAgentSources` | `List<dev.langchain4j.rag.content.Content>` | RAG retrieval populated `Result.sources()` | | `CamelLangChain4jAgentToolExecutions` | `List<dev.langchain4j.service.tool.ToolExecution>` | Tools were invoked during the agent call | Native LangChain4j objects are stored on the exchange (same approach as `FinishReason` and chat’s RAG input header), not JSON-serialized strings. ### Changes - **`Headers.java`** — new `SOURCES` and `TOOL_EXECUTIONS` constants with `@Metadata` - **`LangChain4jAgentProducer.java`** — `populateTokenUsageHeaders` renamed to `populateResultHeaders`; sources and tool executions populated when present - **`LangChain4jAgentResultHeadersTest.java`** — 5 unit tests covering full metadata, empty lists, absent fields, sources-only, and tools-only - **Generated metadata** — component JSON, catalog JSON, endpoint DSL header accessors - **Upgrade guide** — note added under `camel-langchain4j-agent` in `camel-4x-upgrade-guide-4_22.adoc` ### Test plan - [x] `LangChain4jAgentResultHeadersTest` — 5/5 passed - [ ] Full `camel-langchain4j-agent` module tests in CI -- 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]
