Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [FEATURE] support non Result return types for AiService when tool…

  1. User

    ISSUE DESCRIPTION

    [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 void or all return null or 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.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /langchain4j, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure and finding code related to AiService, ReturnBehavior, and IMMEDIATE tool execution.

  3. Assistant

    Let me examine the ReturnBehavior enum and the core AiService/ToolService handling of IMMEDIATE results.

  4. Assistant

    Next I'll inspect how ToolService and DefaultAiServices enforce Result return types and how existing IMMEDIATE tests are structured.

  5. Assistant

    I'll read the immediate-return path in DefaultAiServices and the existing IMMEDIATE tool tests.

  6. Assistant

    I'll check the Quarkus PR reference, AiServiceStreamingResponseHandler, and tests that cover non-Result + IMMEDIATE cases.

  7. Assistant

    I'll inspect tool execution result types and the streaming immediate-return path next.

  8. Assistant

    I'll search for type-resolution helpers and any prior work or PR notes on non-Result IMMEDIATE returns.

  9. Assistant

    Checking how isReturnTypeResult is used and scanning for validation around IMMEDIATE return types.

  10. Assistant

    Checking void-return handling and looking for similar resolution logic elsewhere in the codebase.

  11. Assistant

    I'll inspect DefaultToolExecutor for void/null tool results and review DefaultAiServices imports/structure for where to add resolution.

  12. Assistant

    Let me look at the DefaultToolExecutor execute method more carefully for void returns, and also read lines around 157-195.

  13. Assistant

    Checking for tests that expect IllegalConfigurationException when IMMEDIATE is used without Result.

  14. Assistant

    Checking for existing primitive-boxing utilities in the codebase.

  15. Assistant

    Implementing the feature: updating ToolService to allow non-Result returns (with TO_LLM guards), then resolving the immediate result in DefaultAiServices.

  16. Assistant

    Editing the immediate-return branch in ToolService.

  17. Assistant

    Now replace the shouldReturnImmediately block.

  18. Assistant

    Need to navigate to the line first.

  19. Assistant

    Now I can replace since I'm at the right location.

  20. Assistant

    I'll add a helper on ToolService to resolve the immediate return value from tool executions.

  21. Assistant

    Updating DefaultAiServices to resolve non-Result immediate tool returns.

  22. Assistant

    Switching to DefaultAiServices for the immediate-return handling changes.

  23. Assistant

    I'll update the immediateToolReturn handling and add the import.

  24. Assistant

    Need to go to line 55 first

  25. Assistant

    Let me do the import replace and the method body replace.

  26. Assistant

    Now update the immediate return handling block.

  27. Assistant

    Now replace the immediate return block.

  28. Assistant

    Updating ReturnBehavior Javadoc and the tools tutorial docs to reflect non-Result support.

  29. Assistant

    Update the javadocs for ReturnBehavior.

  30. Assistant

    Also update IMMEDIATE and IMMEDIATE_IF_LAST enum constant docs.

  31. Assistant

    Update IMMEDIATE_IF_LAST too.

  32. Assistant

    Fixing the Javadoc typo: {\code TO_LLM} → {@code TO_LLM}.

  33. Assistant

    Updating the tools tutorial documentation next.

  34. Assistant

    I'll update the note section and add an example for non-Result return types.

  35. Assistant

    I'll update the IMMEDIATE_IF_LAST doc note that still claims Result-only support.

  36. Assistant

    Need to update that line.

  37. Assistant

    Replace lineetable 1522

  38. Assistant

    Cleaning up resolveImmediateToolReturn to use TypeUtils.getRawClass, then writing a temporary verification test.

  39. Assistant

    Need to navigate first

  40. Assistant

    Let me replace imports and the method body.

  41. Assistant

    Now update the resolve method to use Type and TypeUtils.

  42. Assistant

    Update resolveImmediateToolReturn signature to use Type and TypeUtils.getRawClass

  43. Assistant

    Writing a temporary verification test and running existing related unit tests.

  44. Assistant

    I'll avoid adding permanent tests — writing a temporary test outside the repo and running it with Maven.

  45. Assistant

    Compiling the affected modules and running the smoke test.

  46. Assistant

    HOME isn't set in this environment — setting it and retrying the build.

  47. Assistant

    Compilation succeeded. Running the smoke test next.

  48. Assistant

    Need full classpath. Let me get it properly.

  49. Assistant

    The classpath should prefer local target/classes (with my changes) over the installed SNAPSHOT jar.

  50. Assistant

    The smoke test had the wrong package declaration; fixing and re-running it.

  51. Assistant

    Parameter names are stripped without -parameters; checking how other tests handle that.

  52. Assistant

    Adding @P parameter annotations so the smoke test works without -parameters.

  53. Assistant

    Need to import ToolService

  54. Assistant

    Checking how @P defines parameter names.

  55. Assistant

    Need @P(name = "a"), not @P("a").

  56. Assistant

    Fixing the smoke test: null String tool results hit a pre-existing message-building issue, so I'll use a nullable non-String type instead.

  57. Assistant

    Smoke tests passed. Running existing ReturnBehavior and IMMEDIATE-related unit tests next.

  58. Assistant

    Fixing a bug: multi-round tool loops can accumulate prior executions, so non-Result mapping must use only the current turn's tools.

  59. Assistant

    I'll add the immediate turn's tool executions separately to ToolServiceResult, or add a field for immediate-return tools only. I think the cleanest approach is to extend ToolServiceResult with a new field like immediateReturnValue (Object) and immediateReturnType (Type), so we can resolve the value directly when we have the current turn's tools.

  60. Assistant

    Updating DefaultAiServices so non-Result mapping only uses the current hail turn’s tool executions.

  61. Assistant

    I'll put the helper on ToolService itself next to resolveImmediateToolReturn.

  62. Assistant

    Now add toolExecutionsForImmediateReturn to ToolService.

  63. Assistant

    Wrong file open — switching back to ToolService.

  64. Assistant

    Adding toolExecutionsForImmediateReturn after resolveImmediateToolReturn / box.

  65. Assistant

    Rebuilding and re-running tests after the multi-round fix.

  66. Assistant

    Adding the multi-round case with a shell edit, then rerunning the unit tests.

  67. Assistant

    Verifying the final diff and cleaning up residual files.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.