Skip to content

CI 평가

Potato 평가를 여러분의 pytest 스위트 안에서 실행하고 점수 임계값으로 CI 통과 여부를 결정하세요. 에이전트 품질을 떨어뜨리는 프롬프트나 모델 변경이 단위 테스트처럼 빌드를 실패시킵니다. expect() 어서션 API와 GitHub Actions 워크플로 예제가 포함되어 있습니다.

Potato 평가를 여러분의 pytest 스위트 안에서 실행하고, 집계 점수 임계값으로 CI 통과 여부를 결정하세요. 품질을 떨어뜨리는 프롬프트나 모델 변경은 단위 테스트가 깨질 때와 똑같은 방식으로 빌드를 실패시킵니다. 프로그래밍 방식 평가기데이터셋과 실험 위에 얹는 "평가 운영화" 계층입니다.

설치

플러그인은 Potato와 함께 배포되며, 설치하면 자동으로 로드됩니다.

bash
pip install -e .          # registers the `potato_eval` pytest plugin

설치하지 않고 쓰려면 명시적으로 로드하세요. pytest -p potato.testing.pytest_plugin

평가 테스트 작성

테스트에 @pytest.mark.potato_eval를 표시하고 potato_eval 픽스처를 요청하세요.

python
import pytest
from potato.testing import expect
 
@pytest.mark.potato_eval
@pytest.mark.parametrize("case", CASES, ids=[c["q"] for c in CASES])
def test_agent(case, potato_eval):
    out = my_agent(case["q"])
    potato_eval.log_inputs({"question": case["q"]})
    potato_eval.log_outputs(out)
    potato_eval.log_reference_outputs(case["expected"])
 
    potato_eval.log_feedback("correct", 1.0 if out == case["expected"] else 0.0)
    potato_eval.log_feedback("similarity", 1.0 - expect.edit_distance(out, case["expected"]).value)
 
    expect(out).to_contain(case["expected"])   # per-case hard assertion

expect(...).to_equal, .to_contain, .to_be_less_than, .to_be_greater_than, .to_be_between, .to_be_close_to를 제공하며, expect.edit_distance(a, b)expect.embedding_distance(a, b)도 함께 제공합니다. log_feedback 점수는 모든 평가 테스트에 걸쳐 키별 평균으로 집계됩니다.

빌드에 임계값 걸기

bash
pytest tests/eval/ \
  --potato-threshold correct=0.8 \
  --potato-threshold similarity=0.7 \
  --potato-experiment agent-regression
옵션효과
--potato-threshold KEY=MINmean(KEY) < MIN이면 실행을 실패 처리합니다. 여러 번 지정할 수 있습니다.
--potato-experiment DATASET실행을 실험으로 기록합니다.
--potato-no-sync실험 기록을 건너뜁니다.

임계값을 위반하면 실행이 0이 아닌 코드로 종료되어 CI 작업이 실패하고 THRESHOLD FAILED: <key> = <actual> < <min>을 출력합니다. 기록된 실험은 평범한 파일($POTATO_EVAL_STORE, 기본값 ./eval_store)이므로 CI 아티팩트로 업로드할 수 있습니다.

GitHub Actions

예제 워크플로는 examples/agent-traces/ci-eval/ci_workflow_example.yml에 있습니다. 모든 PR에서 스위트를 실행하고, 임계값으로 통과 여부를 판단하며, 실험 기록을 아티팩트로 업로드합니다.

관련 항목