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>
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:
AgenticServices.humanInTheLoopBuilder()
.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
Do not call DeferredResponse.blockingGet() (or complete on a privately cached instance)
inside the responseProvider. That turns this into a thread-blocking wait and
bypasses suspension; use PendingResponse when you intentionally want to block.
- See Also:
-
Field Summary
Fields inherited from interface DelayedResponse
PENDING -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class DeferredResponse
blockingGet, blockingGet, complete, completeExceptionally, isDone, responseId, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DelayedResponse
result
-
Constructor Details
-
SuspendedResponse
-