Prioritization & exploration
When your agent has multiple tasks, prioritization determines what to do first. This pattern scores tasks by urgency, importance, deadlines, and dependencies, then uses AI to recommend an optimal schedule.
class Task:
def __init__(self, name, priority, deadline=None):
self.name = name
self.priority = priority # urgent/high/medium/low
self.deadline = deadline
def get_priority_score(self):
scores = {"urgent": 4, "high": 3, "medium": 2, "low": 1}
return scores.get(self.priority, 1)
class TaskPrioritizer:
def prioritize(self, tasks):
"""Sort tasks by priority score."""
return sorted(tasks, key=lambda t: t.get_priority_score(), reverse=True)
def ai_prioritize(self, tasks, llm):
"""Use AI to analyze business impact and recommend order."""
task_list = "\n".join([f"- {t.name} ({t.priority})" for t in tasks])
prompt = f"Prioritize these tasks by business impact:\n{task_list}"
return llm.generate(prompt).contentTask scoring with urgency-based priority and AI-driven scheduling.
Quiz: Quiz
Loading practice…
Matching exercise: Match priority levels
Loading practice…
Flashcards: Flashcards
Loading practice…
You can now build intelligent task scheduling into your agents. The next pattern takes a different approach: instead of prioritizing known tasks, exploration lets agents discover entirely new areas to investigate.
The exploration pattern enables an AI agent to go beyond answering direct questions. It autonomously generates hypotheses about a topic, tests them, finds connections, and suggests unexplored areas. Think of it as curiosity-driven research.
class ExplorationAgent:
def __init__(self):
self.llm = get_llm()
self.knowledge = []
def generate_hypotheses(self, topic):
prompt = f"Generate 5 testable hypotheses about: {topic}"
return self.llm.generate(prompt).content
def explore_topic(self, topic, depth=2):
hypotheses = self.generate_hypotheses(topic)
for hypothesis in hypotheses:
result = self.research_hypothesis(hypothesis)
self.knowledge.append(result)
if depth > 1:
new_areas = self.discover_new_areas()
for area in new_areas:
self.explore_topic(area, depth - 1)
def discover_new_areas(self):
"""Suggest unexplored areas based on accumulated knowledge."""
prompt = f"""Based on these findings:
{self.knowledge}
What unexplored areas should we investigate next?"""
return self.llm.generate(prompt).contentExplorationAgent generates hypotheses, tests them, and discovers new areas.
Quiz: Quiz
Loading practice…
Flashcards: Flashcards
Loading practice…
You now understand how exploration and discovery patterns help agents find new solutions.