Agent constructor

Agent({
  1. required ToolCallingModel model,
  2. required List<Tool> tools,
  3. String? system,
  4. int maxSteps = 8,
  5. int? maxTokens,
  6. void onStep(
    1. AgentStep step
    )?,
})

Creates an agent.

Implementation

Agent({
  required this.model,
  required this.tools,
  this.system,
  this.maxSteps = 8,
  this.maxTokens,
  this.onStep,
}) {
  if (maxSteps <= 0) {
    throw ArgumentError.value(maxSteps, 'maxSteps', 'must be positive');
  }
  final names = <String>{};
  for (final tool in tools) {
    if (!names.add(tool.name)) {
      throw ArgumentError('two tools are both called "${tool.name}"');
    }
  }
}