Croway opened a new pull request, #22829: URL: https://github.com/apache/camel/pull/22829
## Summary - Handle `null` `finish_reason` in `OpenAIProducer` to avoid NPE when using OpenAI-compatible servers (e.g. mlx-lm) that don't always set this field - Use the SDK's null-safe `_finishReason()` accessor (`JsonField`) instead of the throwing `finishReason()` (`getRequired`) - Default to `"stop"` when `finish_reason` is null or missing ## Context The OpenAI spec says `finish_reason` should always be set, but several popular local model servers (mlx-lm, some llama.cpp versions) return `null` when tools are defined in the request but the model responds without calling any. The openai-java SDK's `finishReason()` method calls `getRequired()` which throws on null, crashing the agentic loop. ## Test plan - [x] Verified with mlx-lm serving Qwen3-35B with MCP tools configured - [ ] Existing unit tests pass (`mvn verify` in camel-openai module) _Claude Code on behalf of Federico Mariani_ -- 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]
