zbendhiba commented on PR #23996:
URL: https://github.com/apache/camel/pull/23996#issuecomment-4719551767
Thanks for the detailed review @Croway.
Here's what I addressed:
**Renamed `responseType` to `outputClass`** to align with `camel-openai`.
The body is now a raw JSON string. No auto-unmarshalling. Users add
`.unmarshal().json(MyClass.class)` in their route. This also removed
`ServiceOutputParser` (which was `@Internal`) and the parse-failure issue where
the original response was lost on exception.
**Fixed validation in `doInit()`**. The guard now enforces all three
conditions when `outputClass` or `jsonSchema` is set: `agentConfiguration` must
be present, `agent` must be absent, `agentFactory` must be absent. The
mutual-exclusion check moved to the top so it fires on all paths.
**Fixed the error message** for non-POJO types. It now says "outputClass
must be a POJO class with public fields or getters. Simple types, enums, and
collections are not supported."
**Fixed schema naming**. I rebuild the derived schema with
`.name("camel_schema")` so both `outputClass` and `jsonSchema` send the same
name to the model.
**Removed the code duplication** in `resolveAndApplyStructuredOutput()`.
Both branches now derive only their `JsonSchema`. The `ResponseFormat` build
and `setResponseFormat` call happen once at the bottom.
**Fixed the race condition** on the `agent` field.
`agentFactory.createAgent(exchange)` was writing a shared field from
`process()` on a singleton producer. Fixed with a local variable.
**Added two unit tests** for the newly guarded configs: `outputClass` +
`agent` bean, and `outputClass` + `agentFactory`.
**Updated the docs** to reflect the rename, raw JSON body semantics, and the
three-condition constraint.
On the `AgentConfiguration.configureBuilder()` suggestion: I kept
`outputClass` intentionally consistent with `jsonSchema`. Both have the same
restriction. Generalizing both through `configureBuilder()` is a broader
change. I think it deserves its own JIRA rather than expanding this PR.
One remaining difference from `camel-openai`: `outputClass` is a `Class<?>`
bound at startup, not a `String` resolved per-request via `ClassResolver` with
a header override. That's a deliberate choice for now. Happy to open a
follow-up if you think full alignment is worth it.
_Claude Code on behalf of Zineb Bendhiba_
--
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]