Interface AgenticService<T,A>
- Type Parameters:
T- the self-referencing builder type (for fluent chaining)A- the type of the built agent proxy
- All Known Subinterfaces:
ConditionalAgentService<T>, LoopAgentService<T>, ParallelAgentService<T>, ParallelMapperService<T>, PlannerBasedService<T>, SequentialAgentService<T>
- All Known Implementing Classes:
ConditionalAgentServiceImpl, LoopAgentServiceImpl, ParallelAgentServiceImpl, ParallelMapperServiceImpl, PlannerBasedServiceImpl, SequentialAgentServiceImpl, SupervisorAgentServiceImpl
public interface AgenticService<T,A>
Fluent builder interface for configuring and assembling an agentic service
composed of one or more sub-agents orchestrated by a planner.
-
Method Summary
Modifier and TypeMethodDescriptionbeforeCall(Consumer<AgenticScope> beforeCall) Registers a callback invoked before each agent call, allowing inspection or modification of theAgenticScope(e.g. to inject variables).build()Builds the agentic service, returning a proxy that can be invoked to execute the configured workflow.compensateOnError(boolean compensateOnError) Enables or disables cross-agent compensation.description(String description) Sets the description of this agentic service.errorHandler(Function<ErrorContext, ErrorRecoveryResult> errorHandler) Registers an error handler that is invoked when a sub-agent fails.listener(AgentListener listeners) Registers anAgentListenerto observe agent invocations, tool executions, and lifecycle events within this agentic service.Sets the name of this agentic service.output(Function<AgenticScope, Object> output) Sets a custom function to extract the final output from theAgenticScopeat the end of the workflow.Sets a strongly typed key for the output variable, enforcing type safety when retrieving the result from theAgenticScope.Sets the key under which the final output of this workflow is stored in theAgenticScope.Sets the sub-agents that participate in this agentic workflow.subAgents(Collection<?> agents) Sets the sub-agents that participate in this agentic workflow.
-
Method Details
-
build
A build()Builds the agentic service, returning a proxy that can be invoked to execute the configured workflow.- Returns:
- the built agent proxy
-
subAgents
-
subAgents
Sets the sub-agents that participate in this agentic workflow.- Parameters:
agents- a collection of sub-agents to orchestrate- Returns:
- this builder for fluent chaining
-
beforeCall
Registers a callback invoked before each agent call, allowing inspection or modification of theAgenticScope(e.g. to inject variables).- Parameters:
beforeCall- the callback to invoke before each call- Returns:
- this builder for fluent chaining
-
name
-
description
-
outputKey
Sets the key under which the final output of this workflow is stored in theAgenticScope.- Parameters:
outputKey- the name of the output variable- Returns:
- this builder for fluent chaining
-
outputKey
Sets a strongly typed key for the output variable, enforcing type safety when retrieving the result from theAgenticScope. Use this as an alternative tooutputKey(String).- Parameters:
outputKey- the class representing the typed output variable- Returns:
- this builder for fluent chaining
-
output
Sets a custom function to extract the final output from theAgenticScopeat the end of the workflow. Use this when the output requires transformation or aggregation beyond a simple key lookup.- Parameters:
output- a function that receives the scope and returns the output- Returns:
- this builder for fluent chaining
-
errorHandler
Registers an error handler that is invoked when a sub-agent fails. The handler receives anErrorContextand returns anErrorRecoveryResultindicating whether to propagate the exception, retry the failed agent, or return a fallback result.- Parameters:
errorHandler- the error handling function- Returns:
- this builder for fluent chaining
-
compensateOnError
Enables or disables cross-agent compensation. When enabled and any agent in the hierarchy fails, all previously successful tool invocations that have@CompensateForactions are compensated in reverse chronological order, making the workflow's side effects atomic. Defaults tofalse.- Parameters:
compensateOnError- whether to enable cross-agent compensation- Returns:
- this builder for fluent chaining
-
listener
Registers anAgentListenerto observe agent invocations, tool executions, and lifecycle events within this agentic service.- Parameters:
listeners- the listener to register- Returns:
- this builder for fluent chaining
-