forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson_reuse_bench.py
More file actions
69 lines (57 loc) 路 2.34 KB
/
Copy pathlesson_reuse_bench.py
File metadata and controls
69 lines (57 loc) 路 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import argparse
import json
import os
from agents import YourAgent # Import your agent class
# Define the task pairs
TASK_PAIRS = {
"DCO": ["Missing sign-off", "Wrong email variant"],
"Secret Scan": ["Token in commit", "Actions secret variant"],
"DB Lock": ["SQLite locked", "Agent state DB variant"]
}
# Function to run the benchmark
def run_benchmark(agent, with_lessons, dry_run=False):
scores = []
for pair, tasks in TASK_PAIRS.items():
task_a, task_b = tasks
if dry_run:
print(f"Running {pair} - Task A: {task_a}, Task B: {task_b}")
continue
# Run Task A
result_a = agent.run(task_a)
# Store the lesson from Task A
lesson = agent.get_lesson(result_a) if with_lessons else None
# Run Task B
if with_lessons:
result_b = agent.run(task_b, lesson=lesson)
else:
result_b = agent.run(task_b)
# Calculate the score
score = calculate_score(result_b)
scores.append(score)
return sum(scores) / len(scores)
# Function to calculate the score
def calculate_score(result):
# Placeholder for actual score calculation
return 1.0 if result == "success" else 0.0
# Main function
def main():
parser = argparse.ArgumentParser(description="Run LessonReuseBench benchmark")
parser.add_argument("--agent", type=str, required=True, help="Name of the agent to use")
parser.add_argument("--compare", action="store_true", help="Run both with and without lessons")
parser.add_argument("--dry-run", action="store_true", help="Validate structure without running the benchmark")
args = parser.parse_args()
# Initialize the agent
agent = YourAgent(args.agent)
# Run the benchmark
if args.compare:
with_lessons_score = run_benchmark(agent, with_lessons=True, dry_run=args.dry_run)
without_lessons_score = run_benchmark(agent, with_lessons=False, dry_run=args.dry_run)
delta = with_lessons_score - without_lessons_score
print(f"With lessons: {with_lessons_score:.2f}")
print(f"Without lessons: {without_lessons_score:.2f}")
print(f"Delta: {delta:.2f}")
else:
score = run_benchmark(agent, with_lessons=True, dry_run=args.dry_run)
print(f"Score: {score:.2f}")
if __name__ == "__main__":
main()