Skip to content

Exceptions Reference

All AgentEnsemble exceptions extend AgentEnsembleException, which itself extends RuntimeException. All exceptions are unchecked.


java.lang.RuntimeException
net.agentensemble.exception.AgentEnsembleException
ValidationException
TaskExecutionException
AgentExecutionException
MaxIterationsExceededException
PromptTemplateException
ToolExecutionException

Package: net.agentensemble.exception

Base class for all framework exceptions. Catch this to handle any AgentEnsemble error with a single catch block.

catch (AgentEnsembleException e) {
log.error("Ensemble error: {}", e.getMessage(), e);
}

Thrown by: Agent.build(), Task.build(), EnsembleMemory.build(), Ensemble.run()

Indicates an invalid configuration. Always thrown before any LLM calls, so there is no partial state.

Common messages:

  • "Agent role must not be blank"
  • "Agent llm must not be null"
  • "Agent maxIterations must be > 0, got: 0"
  • "Ensemble must have at least one task"
  • "Task 'X' references agent 'Y' which is not in the ensemble's agent list"
  • "Ensemble maxDelegationDepth must be > 0, got: 0"
  • "Circular context dependency detected involving task: 'X'"
  • "EnsembleMemory must have at least one memory type enabled"

Thrown by: SequentialWorkflowExecutor

A task failed during execution. Contains partial results from tasks that completed before the failure.

Methods:

MethodTypeDescription
getTaskDescription()StringDescription of the task that failed
getAgentRole()StringRole of the agent assigned to the failed task
getCompletedTaskOutputs()List<TaskOutput>Outputs of tasks that completed successfully before the failure

Thrown by: AgentExecutor

The LLM call failed (API error, network error, timeout, etc.).

Methods:

MethodTypeDescription
getAgentRole()StringRole of the agent that failed
getTaskDescription()StringDescription of the task being executed

Thrown by: AgentExecutor

The agent exceeded its maxIterations limit and did not produce a final answer after receiving stop messages.

Methods:

MethodTypeDescription
getAgentRole()StringRole of the agent
getTaskDescription()StringDescription of the task
getMaxIterations()intThe configured limit
getActualIterations()intThe actual number of iterations

Thrown by: TemplateResolver during Ensemble.run()

One or more {variable} placeholders in task descriptions or expected outputs were not resolved because the corresponding key was not in the inputs map.

Methods:

MethodTypeDescription
getMissingVariables()List<String>Names of the unresolved variables

Thrown by: LangChain4jToolAdapter

A @Tool-annotated method threw an exception during execution. The exception is typically wrapped in an AgentExecutionException.


Thrown by: AgentExecutor when an InputGuardrail or OutputGuardrail configured on a Task returns a failure result.

Propagates through the workflow executor and is wrapped in TaskExecutionException — catch TaskExecutionException and inspect getCause() to detect guardrail failures.

Input violations are thrown before any LLM call is made. Output violations are thrown after the agent response (and after structured output parsing when outputType is set).

Methods:

MethodTypeDescription
getGuardrailType()GuardrailTypeINPUT (pre-execution) or OUTPUT (post-execution)
getViolationMessage()StringThe failure reason returned by the guardrail
getTaskDescription()StringDescription of the blocked task
getAgentRole()StringRole of the agent assigned to the task

See the Error Handling guide for patterns and examples.