Introduction
We set clear goals to know when an agent has done a good job. This helps the agent learn and improve.
Jump into concepts and practice - no test required
success_criteria = {
'goal': 'Description of what success means',
'metrics': ['list', 'of', 'measurable', 'indicators'],
'thresholds': {'metric_name': value, ...}
}success_criteria = {
'goal': 'Clean the room with no trash left',
'metrics': ['trash_collected', 'time_taken'],
'thresholds': {'trash_collected': 100, 'time_taken': 30}
}success_criteria = {
'goal': 'Answer customer questions correctly',
'metrics': ['accuracy', 'response_time'],
'thresholds': {'accuracy': 0.9, 'response_time': 5}
}class Agent: def __init__(self, success_criteria): self.success_criteria = success_criteria def evaluate(self, results): for metric, threshold in self.success_criteria['thresholds'].items(): value = results.get(metric, 0) if metric == 'time_taken' or metric == 'response_time': if value > threshold: return False else: if value < threshold: return False return True # Define success criteria for a cleaning robot success_criteria = { 'goal': 'Clean the room with no trash left', 'metrics': ['trash_collected', 'time_taken'], 'thresholds': {'trash_collected': 100, 'time_taken': 30} } # Create agent agent = Agent(success_criteria) # Simulated results from agent's task results = {'trash_collected': 100, 'time_taken': 28} # Check if agent succeeded success = agent.evaluate(results) print(f"Agent success: {success}")
success?
accuracy = 0.85 threshold = 0.8 success = accuracy >= threshold
success_metric = 0.92
if success_metric = 0.9:
print('Agent succeeded')