Class SuspendedResponse<T>

java.lang.Object
dev.langchain4j.agentic.internal.DeferredResponse<T>
dev.langchain4j.agentic.internal.SuspendedResponse<T>
Type Parameters:
T - the type of the response value
All Implemented Interfaces:
DelayedResponse<T>

public class SuspendedResponse<T> extends DeferredResponse<T>
A DeferredResponse that suspends the agentic system instead of blocking.

When the agentic system encounters this response, it checkpoints its state (if a AgenticScopeStore is configured) and throws AgenticSystemSuspendedException, releasing the calling thread. The system can be resumed later by completing the response via AgenticScope.completePendingResponse(String, Object) and re-invoking the agent method with the same memory ID.

Usage with HumanInTheLoop:

HumanInTheLoop.builder()
    .responseProvider(scope -> new SuspendedResponse<>("user-approval"))
    .build();

// After suspension, from an external system:
scope.completePendingResponse("user-approval", "approved");
// Then re-invoke the agent method with the same memory ID
See Also:
  • Constructor Details

    • SuspendedResponse

      public SuspendedResponse(String responseId)