returnStoppedResponse method

AgentFinish returnStoppedResponse(
  1. AgentEarlyStoppingMethod earlyStoppingMethod,
  2. List<AgentStep> intermediateSteps
)
inherited

Return response when agent has been stopped due to max iterations.

Implementation

AgentFinish returnStoppedResponse(
  final AgentEarlyStoppingMethod earlyStoppingMethod,
  final List<AgentStep> intermediateSteps,
) {
  return switch (earlyStoppingMethod) {
    AgentEarlyStoppingMethod.force => const AgentFinish(
        returnValues: {
          agentReturnKey:
              'Agent stopped due to iteration limit or time limit.',
        },
      ),
    _ => throw LangChainException(
        message:
            'Got unsupported early stopping method: $earlyStoppingMethod.',
      ),
  };
}