Bird
Raised Fist0
Agentic AIml~5 mins

Defining success criteria for agents in Agentic AI

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
We set clear goals to know when an agent has done a good job. This helps the agent learn and improve.
When you want a robot to clean a room and know when it's done well.
When you build a chatbot and want to check if it answers questions correctly.
When training a game-playing AI to win or reach a target score.
When creating a recommendation system to see if users like the suggestions.
When developing a self-driving car to ensure it drives safely and reaches destinations.
Syntax
Agentic AI
success_criteria = {
    'goal': 'Description of what success means',
    'metrics': ['list', 'of', 'measurable', 'indicators'],
    'thresholds': {'metric_name': value, ...}
}
The 'goal' explains in simple words what success looks like.
Metrics are numbers or scores that show how well the agent is doing.
Examples
This means the agent must collect all trash and finish within 30 minutes.
Agentic AI
success_criteria = {
    'goal': 'Clean the room with no trash left',
    'metrics': ['trash_collected', 'time_taken'],
    'thresholds': {'trash_collected': 100, 'time_taken': 30}
}
The chatbot should answer 90% correctly and respond within 5 seconds.
Agentic AI
success_criteria = {
    'goal': 'Answer customer questions correctly',
    'metrics': ['accuracy', 'response_time'],
    'thresholds': {'accuracy': 0.9, 'response_time': 5}
}
Sample Model
This code defines what success means for a cleaning robot and checks if the robot met those goals based on its results.
Agentic AI
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}")
OutputSuccess
Important Notes
Success criteria should be clear and measurable to guide the agent effectively.
Choose metrics that directly relate to the agent's task and goals.
Thresholds set the minimum level for success; adjust them based on real needs.
Summary
Defining success criteria helps agents know what to achieve.
Use clear goals, measurable metrics, and thresholds to set success.
Evaluating results against criteria shows if the agent succeeded.

Practice

(1/5)
1. Why is it important to define success criteria for an AI agent?
easy
A. It reduces the size of the agent's code.
B. It helps the agent understand what goal to achieve.
C. It makes the agent run faster.
D. It allows the agent to ignore errors.

Solution

  1. Step 1: Understand the role of success criteria

    Success criteria tell the agent what outcome is desired or considered good.
  2. Step 2: Connect success criteria to agent behavior

    Without clear goals, the agent cannot know what to aim for or when it has succeeded.
  3. Final Answer:

    It helps the agent understand what goal to achieve. -> Option B
  4. Quick Check:

    Success criteria = clear goals [OK]
Hint: Success criteria define the agent's goal clearly [OK]
Common Mistakes:
  • Thinking success criteria speed up the agent
  • Confusing success criteria with code size
  • Believing success criteria ignore errors
2. Which of the following is the correct way to express a success criterion for an agent in code?
easy
A. success == accuracy > 0.9
B. success = accuracy = 0.9
C. success = accuracy > 0.9
D. success => accuracy > 0.9

Solution

  1. Step 1: Identify correct comparison syntax

    In Python, to assign a boolean result, use a single = with a comparison expression on the right.
  2. Step 2: Check each option's syntax

    success = accuracy > 0.9 uses correct assignment and comparison. success = accuracy = 0.9 uses = instead of == for comparison. success == accuracy > 0.9 uses == incorrectly for assignment. success => accuracy > 0.9 uses => which is invalid in Python.
  3. Final Answer:

    success = accuracy > 0.9 -> Option C
  4. Quick Check:

    Assignment with comparison uses = and > [OK]
Hint: Use '=' for assignment, '>' for comparison [OK]
Common Mistakes:
  • Using '==' instead of '=' for assignment
  • Using '=' instead of '==' for comparison
  • Using invalid operators like '=>'
3. Given the code below, what will be the value of success?
accuracy = 0.85
threshold = 0.8
success = accuracy >= threshold
medium
A. True
B. Error
C. 0.85
D. False

Solution

  1. Step 1: Compare accuracy and threshold values

    Accuracy is 0.85, threshold is 0.8, so 0.85 >= 0.8 is True.
  2. Step 2: Assign comparison result to success

    The boolean True is assigned to success.
  3. Final Answer:

    True -> Option A
  4. Quick Check:

    0.85 >= 0.8 = True [OK]
Hint: Check if accuracy meets or exceeds threshold [OK]
Common Mistakes:
  • Confusing value 0.85 with boolean True
  • Thinking comparison returns a number
  • Expecting an error from valid comparison
4. The following code is intended to check if an agent's success metric is above 90%, but it has a bug. What is the bug?
success_metric = 0.92
if success_metric = 0.9:
    print('Agent succeeded')
medium
A. Missing colon ':' after if statement
B. Print statement syntax error
C. Incorrect variable name 'success_metric'
D. Using '=' instead of '==' in the if condition

Solution

  1. Step 1: Identify the if statement syntax

    In Python, '=' is for assignment, '==' is for comparison in conditions.
  2. Step 2: Locate the bug in the if condition

    The code uses '=' instead of '==' which causes a syntax error.
  3. Final Answer:

    Using '=' instead of '==' in the if condition -> Option D
  4. Quick Check:

    Use '==' for comparison in if [OK]
Hint: Use '==' to compare values in if statements [OK]
Common Mistakes:
  • Confusing '=' with '==' in conditions
  • Ignoring syntax errors from wrong operators
  • Assuming missing colon is the error
5. You want to define success criteria for an agent that completes tasks with at least 95% accuracy and finishes within 10 seconds. Which of the following is the best way to define this success criteria in code?
hard
A. success = (accuracy >= 0.95) and (time_taken <= 10)
B. success = accuracy > 0.95 or time_taken < 10
C. success = accuracy == 0.95 and time_taken == 10
D. success = accuracy >= 0.95 and time_taken > 10

Solution

  1. Step 1: Understand the criteria requirements

    The agent must have accuracy at least 95% and finish within 10 seconds.
  2. Step 2: Translate criteria into logical conditions

    Use '>=' for accuracy and '<=' for time, combined with 'and' to require both.
  3. Step 3: Evaluate each option

    success = (accuracy >= 0.95) and (time_taken <= 10) correctly uses 'and' and proper comparisons. success = accuracy > 0.95 or time_taken < 10 uses 'or' which allows passing if only one condition is met. success = accuracy == 0.95 and time_taken == 10 uses '==' which is too strict. success = accuracy >= 0.95 and time_taken > 10 allows time_taken > 10 which breaks the time limit.
  4. Final Answer:

    success = (accuracy >= 0.95) and (time_taken <= 10) -> Option A
  5. Quick Check:

    Both accuracy and time must meet thresholds [OK]
Hint: Use 'and' to combine all success conditions [OK]
Common Mistakes:
  • Using 'or' instead of 'and' to combine conditions
  • Using '==' instead of '>=' or '<='
  • Allowing time greater than limit