Skip to content
Announcements4 min read

コーディングエージェントアノテーションの提供開始:Claude Code、Aider、SWE-Agentのトレースを評価する

Potatoがコーディングエージェントのアノテーションに対応しました。diffの描画、ターミナル出力の表示、プロセス報酬スキーマを備え、Claude Code、Aider、SWE-Agentからトレースを取り込めます。

Potato Team

なぜコーディングエージェントのアノテーションが要るのか

Claude Code、Aider、SWE-Agentのようなコーディングエージェントは短期間で実用的になり、その仕事ぶりを採点する必要が実際に出てきました。1回の実行は入り組んだトラジェクトリで、コードの編集、ターミナルコマンド、ファイルの読み取り、推論のステップが数珠つなぎになっています。より良いエージェントを訓練するにはその実行に対する人間のフィードバックが要りますが、多くのチームが持っていたアノテーションツールは、この種のデータのために作られたものではありませんでした。

素のテキストアノテーションインターフェースでは、統一diffを描画することも、ターミナル出力を整形することも、エージェントトレースの入れ子構造を扱うこともできません。その結果、各研究室が自前の評価UIを書くことになり、同じ作業を繰り返したうえに、互いに噛み合わないデータセットが残ります。

Potatoはコーディングエージェントのアノテーションを直接扱えるようになりました。トレース向けに作られた描画コンポーネント、この種の評価に合わせたアノテーションスキーマ、訓練にそのまま流し込めるエクスポートが揃っています。機能の完全なリファレンスはコーディングエージェントアノテーションのドキュメントと、より広いエージェント評価ガイドを参照してください。

CodingTraceDisplay:トレースビューア

アノテーション体験の大部分はCodingTraceDisplayコンポーネントを通ります。エージェントのトラジェクトリの各ステップを、そのステップ種別に合った可視化で描画します。

Potatoでのコーディングエージェントアノテーションのインターフェースはこのようになります。

diffの描画とファイルツリーを表示するコーディングエージェントのトレース表示CodingTraceDisplayはコードのdiff、ターミナル出力、ファイルの読み取りを適切な書式で描画します

統一diff表示

コードの編集は、削除行と追加行を赤と緑でハイライトした統一diffとして描画されます。diff表示には行番号、ファイルパスのヘッダー、変更周辺のコンテキスト行が含まれます。多くの開発者が既に慣れているGitHubのプルリクエストと同じ見え方です。

yaml
# The diff rendering is automatic when your trace data includes tool_use
# steps with file edit operations. No special config is needed.
coding_agent:
  display:
    diff_style: "unified"         # "unified" or "split" side-by-side
    context_lines: 3              # Lines of context around changes
    syntax_highlighting: true     # Language-aware highlighting
    collapse_large_diffs: true    # Auto-collapse diffs > 100 lines
    large_diff_threshold: 100

暗色のターミナルブロック

bashコマンドとその出力は、等幅フォントの暗色ターミナルブロックとして描画され、ANSIカラーに対応し、長い結果はスクロールできます。ターミナルブロックには実行したコマンド、作業ディレクトリ、終了コードが表示されます。

yaml
coding_agent:
  display:
    terminal_theme: "dark"        # "dark" or "light"
    max_terminal_height: 400      # pixels, scrollable beyond this
    show_exit_codes: true
    show_working_directory: true
    ansi_colors: true             # Render ANSI escape sequences

行番号付きのコードブロック

ファイルの読み取りは、シンタックスハイライトと行番号の付いたコードブロックとして表示されます。エージェントが特定の行範囲を読んだ場合は、その範囲だけが元の行番号を保ったまま表示されるので、実ファイルと突き合わせやすくなります。

ファイルツリーのサイドバー

折りたたみ可能なサイドバーに、トラジェクトリ中で触れたファイルがツリー構造で並びます。各ファイルには、作成・変更・読み取り・削除のいずれかを示すアイコンが付きます。ツリー内のファイルをクリックすると、そのファイルがトレースで最初に登場する箇所までスクロールします。

yaml
coding_agent:
  display:
    file_tree:
      enabled: true
      position: "left"            # "left" or "right"
      show_change_icons: true     # Icons for created/modified/deleted
      group_by: "directory"       # "directory" or "chronological"

折りたたみ可能な出力

どのステップ種別でも、長い出力は折りたたんでトレースを読みやすく保てます。アノテーターは必要なステップだけ個別に展開することも、「Expand All」「Collapse All」のコントロールを使うこともできます。エージェントの思考・推論ブロックは既定で折りたたまれますが、必要なら確認できます。

yaml
coding_agent:
  display:
    collapsible:
      auto_collapse_thinking: true
      auto_collapse_long_output: true
      long_output_threshold: 50   # lines
      default_expanded_types:     # These step types start expanded
        - "file_edit"
        - "bash_command"

プロセス報酬モデル(PRM)スキーマ

プロセス報酬モデルは、最終的な結果だけを評価するのではなく、ステップ単位で功罪を割り当てます。Potatoは、速度と精度のバランスが異なる2つのPRMアノテーションモードに対応しています。

first-errorモード

first-errorモードでは、アノテーターがトラジェクトリをスクロールして、エージェントが最初に誤ったステップをクリックします。クリックしたステップより前はすべて自動的に正しいとマークされ、それ以降(クリックしたステップを含む)はすべて自動的に誤りとマークされます。判断すべき箇所が1つで済むので、アノテーションは大幅に速くなります。

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: prm_first_error
    mode: "first_error"
    description: "Click the first step where the agent makes an error"

ステップごとモード

ステップごとモードでは、すべてのステップに独立した評価を付けます。より詳細な訓練データが得られる一方、トレース1件あたりの時間は長くなります。アノテーターは各ステップを正しい、誤り、部分的に正しいのいずれかで評価します。

yaml
annotation_schemes:
  - annotation_type: process_reward
    name: prm_per_step
    mode: "per_step"

コードレビュースキーマ

コードレビューのインターフェースは、GitHubのPRと同じ形のアノテーション操作を提供します。

diff行へのインラインコメント付きのコードレビューアノテーションアノテーターはdiffの行をクリックしてインラインコメントを付け、ファイルを評価し、承認・却下の判定を下せます

コードレビュースキーマは、GitHubのPRと同じ形のアノテーションをエージェントトレースに持ち込みます。アノテーターはdiff内の特定の行にインラインコメントを残し、ファイルごとに評価を付け、全体の判定を示せます。

yaml
annotation_schemes:
  - annotation_type: code_review
    name: agent_review
    comment_categories:
      enabled: true
      categories:                 # Optional categorization for comments
        - "Bug"
        - "Style"
        - "Logic Error"
        - "Unnecessary Change"
        - "Missing Error Handling"
    file_rating_dimensions:
      enabled: true
      scale: [1, 2, 3, 4, 5]
      labels: ["Poor", "Below Average", "Acceptable", "Good", "Excellent"]
    verdict_options:
      enabled: true
      options:
        - value: "approve"
          text: "Approve"
          description: "Changes are correct and complete"
        - value: "request_changes"
          text: "Request Changes"
          description: "Changes need fixes before merging"
        - value: "comment"
          text: "Comment"
          description: "General feedback, no strong opinion"

トレースコンバータ:どのエージェントからでも取り込む

Potatoには、よく使われる3つのコーディングエージェント形式のコンバータが同梱されています。コンバータは各形式を、Potato内部の構造化トレース表現に正規化します。

Claude Code(Anthropic Messages API)

Claude CodeのトレースはAnthropic Messages APIの形式で、tool_usetool_resultのコンテンツブロックを使います。コンバータはツール呼び出しからファイルの編集、bashコマンド、ファイルの読み取りを抽出し、アシスタントの推論テキストも保持します。

bash
# Convert Claude Code traces to Potato format
potato convert-traces \
  --format claude_code \
  --input ./claude_traces/ \
  --output ./potato_data/traces.jsonl

Aider(編集ブロック付きのMarkdownチャット)

Aiderは、SEARCH/REPLACEの編集ブロックを含むMarkdown形式のチャットログを出力します。コンバータはこれらのブロックを解析してファイルの編集を再構成し、フェンス付きコードブロックからシェルコマンドを抽出します。

bash
# Convert Aider chat logs
potato convert-traces \
  --format aider \
  --input ./aider_logs/ \
  --output ./potato_data/traces.jsonl

SWE-Agent(Thought/Action/Observation)

SWE-Agentはthought/action/observationのループ形式を使います。コンバータはアクションを対応するステップ種別(編集、bash、読み取り)に対応付け、エージェントの思考連鎖を折りたたみ可能な思考ブロックとして保持します。

bash
# Convert SWE-Agent trajectories
potato convert-traces \
  --format swe_agent \
  --input ./swe_agent_trajectories/ \
  --output ./potato_data/traces.jsonl

自動判定

複数のエージェントのトレースが混在している場合、Potatoはファイルごとの構造から形式を自動判定できます。

bash
# Auto-detect format for mixed trace directories
potato convert-traces \
  --format auto \
  --input ./mixed_traces/ \
  --output ./potato_data/traces.jsonl

訓練パイプライン向けのエクスポート

アノテーション済みのトレースは、モデル訓練にそのまま使える形式でエクスポートできます。

PRM形式

プロセス報酬モデルの訓練用に、ステップ単位の報酬ラベルを出力します。

python
# Exported PRM format (one line per trace)
{
  "trace_id": "trace_001",
  "steps": [
    {"step_idx": 0, "content": "Read file src/main.py", "label": "correct"},
    {"step_idx": 1, "content": "Edit src/main.py: fix import", "label": "correct"},
    {"step_idx": 2, "content": "Run tests", "label": "correct"},
    {"step_idx": 3, "content": "Edit src/utils.py: wrong fix", "label": "incorrect"},
    {"step_idx": 4, "content": "Run tests again", "label": "incorrect"}
  ],
  "first_error_step": 3
}

DPO/RLHFの選好ペア

ペアワイズ比較のアノテーションと組み合わせると、PotatoはDirect Preference OptimizationやRLHFの訓練に使える選好ペアを生成します。

python
# Exported preference pair format
{
  "prompt": "Fix the failing test in src/test_utils.py",
  "chosen": {"trace_id": "trace_001", "steps": [...]},
  "rejected": {"trace_id": "trace_002", "steps": [...]},
  "preference_strength": 0.85
}

SWE-bench互換の結果

公開されているベンチマークと直接比較できるよう、SWE-benchの評価ハーネスと互換の形式でアノテーションをエクスポートします。

bash
# Export to SWE-bench format
potato export \
  --format swe_bench \
  --project ./my_project/ \
  --output ./swe_bench_results.json

クイックスタート

何もない状態からアノテーションサーバーが動くまで、5分ほどです。

インストール

bash
pip install potato-annotation[coding-agents]

トレースを変換する

bash
# Convert traces from your coding agent
potato convert-traces \
  --format auto \
  --input ./my_agent_traces/ \
  --output ./data/traces.jsonl

設定ファイルを作る

PRMとコードレビューの両方のスキーマを使う、コーディングエージェント評価プロジェクトの設定は次のとおりです。

yaml
# config.yaml
project_name: "Coding Agent Evaluation"
port: 8000
 
data:
  source: "local"
  input_path: "./data/traces.jsonl"
  data_format: "coding_trace"
 
coding_agent:
  display:
    diff_style: "unified"
    context_lines: 3
    syntax_highlighting: true
    collapse_large_diffs: true
    terminal_theme: "dark"
    max_terminal_height: 400
    show_exit_codes: true
    file_tree:
      enabled: true
      position: "left"
      show_change_icons: true
    collapsible:
      auto_collapse_thinking: true
      auto_collapse_long_output: true
 
annotation_schemes:
  - annotation_type: process_reward
    name: prm_evaluation
    mode: "first_error"
    description: "Click the first step where the agent makes a mistake"
 
  - annotation_type: code_review
    name: code_quality
    comment_categories:
      enabled: true
      categories: ["Bug", "Logic Error", "Style", "Missing Error Handling"]
    file_rating_dimensions:
      enabled: true
      scale: [1, 2, 3, 4, 5]
    verdict_options:
      enabled: true
      options:
        - value: "approve"
          text: "Approve"
        - value: "request_changes"
          text: "Request Changes"
        - value: "comment"
          text: "Comment"
 
  - annotation_type: text
    name: overall_notes
    description: "Additional Notes"
    placeholder: "Any other observations about this trace..."
output:
  path: "./output/"
  format: "jsonl"
  export_formats:
    - "prm"
    - "swe_bench"
 
quality_control:
  inter_annotator_agreement: true
  overlap_percentage: 20
  minimum_time_per_instance: 30  # seconds
 
annotators:
  - username: "annotator1"
  - username: "annotator2"

サーバーを起動する

bash
potato start config.yaml -p 8000

ブラウザでhttp://localhost:8000を開き、ログインしてアノテーションを始めてください。ここまでに説明したdiffの描画、ターミナル出力、プロセス報酬アノテーションがすべて使えます。

この先の予定

これは最初のリリースで、まだやりたいことが残っています。対応するエージェント形式を増やすこと、複数ファイルにまたがるリファクタリングの可視化を良くすること、OpenRLHFやTRLのような訓練フレームワークとの連携を深めることなどです。

新しいトレースコンバータ、スキーマ、エクスポート形式を書いたら、ぜひ貢献してください。コーディングエージェントを評価していて、この仕組みでは扱えないものに突き当たった場合は、GitHubリポジトリにissueを立ててください。