Untitled conversation
- User
[FEATURE] support non Result return types for AiService when tool execution is IMMEDIATE Is your feature request related to a problem? Please describe. If using ReturnBehavior.IMMEDIATE, your AiService method has to return Result even if all tools called return
voidor all returnnullor there's one tool method that returns same type as AiService return type.Describe the solution you'd like I'd like to support non-Result return types for AiService methods when tool execution has IMMEDIATE results based on these rules:
- If ai service method return type is void, just return null
- If any tool executions are TO_LLM throw exception (IMMEDIATE_IF_LAST case)
- If all tool executions have a null result and return type is nullable (not a primitive), then return null
- If there is one non-null tool execution result, and the result can be resolved to the return type, then return that object
I have a PR for this open in Quarkus too:
https://github.com/quarkiverse/quarkus-langchain4j/pull/2529
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the AI Service immediate tool-execution path, add the return-type resolution rules, and run the focused test suite.
- Assistant
rgisn’t installed in this checkout, so I’m using the repository’s standard shell search tools and narrowing directly to the AI Service modules. - Assistant
The existing short-circuit already preserves each tool’s raw Java return object, but it discards the behavior metadata and rejects every non-
Resultservice method. I’m changing that boundary soResultkeeps its current metadata-rich behavior while ordinary return types are resolved from the raw tool results. - Assistant
The implementation and focused regression tests are in place. The first offline test run is blocked by missing locally cached snapshot artifacts, so I’m switching to a reactor build that compiles the required sibling modules from this checkout.
- Assistant
The reactor now compiles all production and test sources successfully. The local Maven cache lacks the Surefire JUnit provider, so I’m doing one final runtime check through the already-compiled regression test class without fetching anything externally.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.