gnodet opened a new pull request, #25216: URL: https://github.com/apache/camel/pull/25216
## Summary Adds two new endpoint options to `camel-openai` for configuring the agentic loop's error handling policies: - **`toolExecutionErrorStrategy`** (default: `repromptModel`): controls whether tool execution exceptions are caught and fed back to the model (`repromptModel`) or propagated to the Camel exchange for standard error handling via `onException`/dead-letter (`failExchange`). This addresses the concern that raw exception messages may leak internal details (connection strings, hostnames) to a third-party LLM provider. - **`hallucinatedToolNameStrategy`** (default: `failExchange`): controls whether unknown/hallucinated tool names throw an `IllegalStateException` (`failExchange`) or send a corrective tool result listing available tools so the model can self-correct (`repromptModel`). This is analogous to LangChain4j's `HallucinatedToolNameStrategy`. Both strategies are applied consistently in `OpenAIProducer` (agentic loop) and `OpenAIToolExecutionProducer` (manual tool loop). Defaults preserve backward compatibility. The existing `maxToolIterations` option bounds retries when `repromptModel` strategies are used. ### Changes - New `ToolExecutionErrorStrategy` enum with `REPROMPT_MODEL` and `FAIL_EXCHANGE` values - New `HallucinatedToolNameStrategy` enum with `FAIL_EXCHANGE` and `REPROMPT_MODEL` values - Updated `OpenAIConfiguration` with two new `@UriParam` fields - Updated `OpenAIProducer.processNonStreamingAgentic()` to branch on both strategies - Updated `OpenAIToolExecutionProducer.process()` to branch on both strategies - Updated `openai-mcp.adoc` error handling documentation - New `OpenAIToolErrorStrategyTest` with 3 tests covering all strategy combinations Cross-references: CAMEL-23943/CAMEL-23944 (langchain4j analogues), CAMEL-23393 (token budget), CAMEL-23382 (unified tool abstraction) ## Test plan - [x] `OpenAIToolErrorStrategyTest.hallucinatedToolNameRepromptModelSendsCorrectiveResultToModel` — verifies `repromptModel` strategy feeds corrective message back to model - [x] `OpenAIToolErrorStrategyTest.hallucinatedToolNameDefaultFailExchangeThrowsException` — verifies default `failExchange` behavior is preserved - [x] `OpenAIToolErrorStrategyTest.toolExecutionErrorFailExchangePropagatesToExchange` — verifies `failExchange` propagates exception to exchange - [x] All existing tests pass (145 unit + 18 integration) - [x] Formatting check passes (`mvn -Psourcecheck validate`) _This PR was created by Claude Code on behalf of gnodet_ 🤖 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]
