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-return path and its existing tests, then implement these conversion rules and run the narrowest relevant test suite.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepto locate the implementation and tests. - Assistant
The raw Java tool return value is already preserved in each
ToolExecution. I’m extending the immediate-result metadata just enough to detect mixedTO_LLMcalls, then resolving zero/one non-null raw values against the AI service method’s declared type. - Assistant
The implementation now compiles. I’ve added focused coverage for void, nullable null, boxed/primitive values, mixed
TO_LLM, multiple values, and incompatible values; I’m running those alongside the existing return-behavior matrix. - Assistant
The new null-result cases exposed an earlier assumption in message construction: an empty tool result could not be represented even though the executor preserves
null. I’m fixing that boundary so null/void results remain valid through immediate execution. - Assistant
All 70 focused AI-service tests now pass, including the existing immediate/
IMMEDIATE_IF_LASTmatrix. I’m doing a broader module regression run and a final diff review; formatting automation is unavailable because this checkout lacks its configuredorigin/mainGit reference, so I’m validating formatting through compilation and diff checks instead. - Assistant
The broader module suite has passed the AI-service/tool tests and is still working through the CPU-heavy embedding tests; there are no failures so far.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.