tinycodinglm / agentic /aiagent-0105.jsonl
winapiadmin's picture
Upload folder using huggingface_hub
1f3a244 verified
|
Raw History Blame Contribute Delete
2.64 kB
opencode trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

How do I evaluate AI agents on task completion, tool accuracy, efficiency and safety, and which benchmarks exist (GAIA, AgentBench, ToolBench, HumanEval)? Show a runnable metrics harness. Include code examples.

Assistant

Evaluate completion, tool use, efficiency, safety.

  • GAIA (General AI Assistants, Mialon et al.): real-world web/code/file tasks
  • AgentBench: multi-environment agent tasks
  • ToolBench: tool-invocation correctness
  • HumanEval: code generation pass@k
python
import time
from dataclasses import dataclass

@dataclass
class AgentMetrics:
    task_completed: bool
    steps_taken: int
    tokens_used: int
    errors: int
    tool_accuracy: float
    seconds: float

    def score(self) -> float:
        steps = max(self.steps_taken, 1)
        toks = max(self.tokens_used, 1)
        return ((1.0 if self.task_completed else 0.0) * 0.4
                + self.tool_accuracy * 0.3
                + min(1.0, 10 / steps) * 0.15
                + min(1.0, 1000 / toks) * 0.15)

def check_answer(answer: str, expected: str) -> bool:
    return (answer or "").strip().lower() == (expected or "").strip().lower()

def evaluate_agent(agent, tasks: list[dict]) -> list[AgentMetrics]:
    results: list[AgentMetrics] = []
    for task in tasks:
        start = time.time()
        answer = agent.run(task["question"])
        elapsed = time.time() - start
        total_calls = max(getattr(agent, "total_tool_calls", 0), 1)
        correct_calls = getattr(agent, "correct_tool_calls", 0)
        results.append(AgentMetrics(
            task_completed=check_answer(answer, task.get("expected", "")),
            steps_taken=max(getattr(agent, "step_count", 1), 1),
            tokens_used=max(getattr(agent, "token_count", 1), 1),
            errors=getattr(agent, "error_count", 0),
            tool_accuracy=correct_calls / total_calls,
            seconds=elapsed,
        ))
    return results