Package akka.javasdk.agent
Interface Agent.Effect.OnSuccessBuilder
- Enclosing interface:
Agent.Effect<T>
public static interface Agent.Effect.OnSuccessBuilder
-
Method Summary
Modifier and TypeMethodDescriptionMap the String response from the model into a different response type.Handle failures that occur during model processing.responseAs
(Class<T> responseType) Parse the response from the model into a structured response of a given responseType.responseConformsTo
(Class<T> responseType) Parse the response from the model into a structured response of a given responseType.Reply with the response from the model.Reply with the response from the model.
-
Method Details
-
thenReply
Agent.Effect<String> thenReply()Reply with the response from the model.- Returns:
- A message reply.
-
thenReply
Reply with the response from the model.- Parameters:
metadata
- The metadata for the message.- Returns:
- A message reply.
-
responseAs
Parse the response from the model into a structured response of a given responseType. The system message must have instruction or example of how the JSON should be structured. Alternatively, or as a compliment, the JSON schema of theresponseType
can be included automatically in the request by usingresponseConformsTo(java.lang.Class<T>)
.- Parameters:
responseType
- The structured response type.- See Also:
-
responseConformsTo
Parse the response from the model into a structured response of a given responseType. The JSON schema of theresponseType
is included in the model request. At least OpenAI and Google Gemini support this structured model output feature. For other models that don't support it, you have to give more detailed instructions about the expected output format in the system message.- Parameters:
responseType
- The structured response type.- See Also:
-
map
Map the String response from the model into a different response type. -
onFailure
Handle failures that occur during model processing. This method allows recovery from various types of exceptions including:ModelException
- General model processing failuresRateLimitException
- API rate limiting exceededModelTimeoutException
- Model request timeoutUnsupportedFeatureException
- Unsupported model featuresInternalServerException
- Internal service errorsJsonParsingException
- Response parsing failuresToolCallLimitReachedException
- Tool call limit exceededToolCallExecutionException
- Function tool execution errorsMcpToolCallExecutionException
- MCP tool execution errors
-