본문 바로가기
C.W.K.
Stream
Lesson 02 of 06 · published

에이전트 평가

~22 min · systems, agents, tools, trajectories

Level 0추측자
0 XP0/55 lessons0/10 achievements
0/150 XP to next level150 XP to go0% complete

최종 답뿐 아니라 실행 과정도 평가해

LLM 에이전트는 반복해서 판단해. 도구를 선택하고 실행한 뒤 결과를 관찰하고, 다음 단계를 결정하지. 최종 답도 중요하지만 어떻게 도달했는지도 중요해. 올바른 도구를 사용했어? 불필요한 단계를 반복했어? 허용할 수 있는 비용 안에서 성공했어?

에이전트 전용 지표

  • 과제 성공 — 에이전트가 목표를 달성했어? 이진 값이나 등급으로 평가할 수 있어.
  • 도구 호출 정확도 — 올바른 도구를 올바른 인자와 함께 선택했어?
  • 실행 과정 효율성 — 완료까지 거친 단계 수가 적절해?
  • 비용 — 총 토큰 수, 총 도구 호출 수, 총 경과 시간을 측정해.
  • 복구 — 초기 단계가 실패했을 때 에이전트가 복구해?
  • 목표 일치 — 에이전트가 사용자의 실제 목표를 추구해, 아니면 도중에 빗나가?

실행 과정 평가 패턴

에이전트가 거치는 모든 단계를 기록해. 사고 과정, 도구 호출, 도구 결과, 다음 사고 과정을 차례로 남기고, (a) 최종 결과와 (b) 실행 과정의 품질을 각각 평가해. "불필요한 도구 호출을 47번 한 뒤 완벽한 답을 냈다"면 평가에서 통과가 아니라 실패로 처리해야 해.

원칙: 에이전트 평가는 반드시 실행 과정을 살펴야 해. 최종 출력만 채점하면 느리고, 비싸고, 실행 도중 혼란을 겪는 등 눈에 잘 띄지 않는 실패의 절반을 놓치게 돼.

안전한 실행을 위한 격리 환경

코드를 실행하거나, 탐색하거나, 상태를 변경하는 에이전트는 격리 환경이 필요해. Inspect AI의 Docker 격리 환경을 사용할 수도 있고, SWE-bench처럼 임시 저장소 복제본을 만들 수도 있어. 실제 인프라에 접근하는 시스템에서는 절대로 격리되지 않은 평가를 실행하지 마.

Code

실행 과정 기록과 단계별 채점·python
from dataclasses import dataclass, field

@dataclass
class AgentStep:
    thought: str
    tool: str
    args: dict
    result: str
    cost: float       # tokens or wall-time

@dataclass
class AgentTrajectory:
    task: str
    steps: list[AgentStep] = field(default_factory=list)
    final_output: str = ""
    success: bool = False

def trajectory_metrics(traj: AgentTrajectory, optimal_steps: int):
    return {
        "success": traj.success,
        "n_steps": len(traj.steps),
        "efficiency": optimal_steps / max(len(traj.steps), 1),
        "total_cost": sum(s.cost for s in traj.steps),
        "unique_tools": len({s.tool for s in traj.steps}),
    }
DeepEval을 활용한 도구 호출 정확도 평가·python
from deepeval.metrics import ToolCallAccuracyMetric, AgentGoalAccuracyMetric
from deepeval.test_case import LLMTestCase, ToolCall

case = LLMTestCase(
    input="What is the weather in Tokyo right now?",
    actual_output="It is 18°C and partly cloudy in Tokyo.",
    tools_called=[
        ToolCall(name="get_weather", arguments={"city": "Tokyo"}),
    ],
    expected_tools=[
        ToolCall(name="get_weather", arguments={"city": "Tokyo"}),
    ],
)
assert_test(case, [ToolCallAccuracyMetric(), AgentGoalAccuracyMetric()])
격리 환경과 Inspect AI 에이전트 평가·python
from inspect_ai import Task, task
from inspect_ai.solver import use_tools, generate
from inspect_ai.tool import bash, python
from inspect_ai.scorer import includes

@task
def coding_agent_task():
    return Task(
        dataset=[Sample(
            input="Find the line count of all .py files under src/ and report the total.",
            target="42",
        )],
        solver=[
            use_tools([bash(), python()]),
            generate(),
        ],
        scorer=includes(),
        sandbox="docker",  # tools execute in isolated container
        message_limit=20,  # caps trajectory length
    )

External links

Exercise

제품에서 에이전트 과제 하나를 골라 20회 실행해. 각 실행의 사고 과정, 도구, 인자, 결과를 기록하고 성공 여부, 단계 수, 비용을 따로 평가해. 성공했지만 단계 수가 많은 사례를 다음 프롬프트 개선 대상으로 삼아.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.