Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. 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 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.

  2. Assistant

    Exploring the codebase to see how AiService handles IMMEDIATE tool execution and return types.

  3. Assistant

    Implementing the merged PR changes in production files.

  4. Assistant

    Implemented support for non-Result AI Service return types when immediate tool return applies.

    Changes

    1. ToolService.java
      Removed the guard that threw IllegalConfigurationException when immediate return happened on a non-Result method. The loop can short-circuit for any return type; resolution happens in DefaultAiServices.

    2. DefaultAiServices.java
      When immediateToolReturn() is true:

      • Result: unchanged — build Result with content(null) and tool execution metadata.
      • void: return null.
      • Other types (only if every tool is IMMEDIATE or IMMEDIATE_IF_LAST):
        • All resultObject() values null → return null
        • Exactly one non-null value assignable to the return type → return that object
        • Otherwise → IllegalConfigurationException with guidance to use Result
      • Mixed with TO_LLM on an immediate-return batch → IllegalConfigurationException (non-immediate tools with non-Result return types)

      Added resolvesToType() for assignability checks.

    3. DefaultToolExecutor.java

      • toContents(null) returns null so void/null tool results keep resultObject() null for immediate return logic.
      • toText handles null String tool results safely.

    Verification

    • ReturnBehaviorCombinationsTest, ProgrammaticCreatedImmediateReturnToolTest, DefaultToolExecutorTest, ToolServiceTest, and broader *Tool*Test — all passed
    • git diff --check — clean
    • Production diff: 3 files, +62 / −17 lines

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