コーディングエージェントアノテーション
diff描画、ターミナル出力、ファイルツリーのナビゲーションを使ってコーディングエージェントのトレースにアノテーションを付けます。Claude Code、Aider、SWE-Agentなどのコーディングアシスタントから取り込めます。
v2.4.0の新機能
コーディングエージェント(Claude Code、Aider、SWE-Agent、OpenHandsなど)が生成するトレースは、汎用のエージェントトレースとは性質が違います。コードdiff、ターミナル出力、ファイルの読み取り、ディレクトリの走査、テスト結果が含まれます。こうしたトレースをレビューするには、コード変更の構造を理解し、ソフトウェアエンジニアが見慣れた形で提示する専用の描画が必要です。
PotatoのCodingTraceDisplayは、コーディングエージェントのセッション向けの専用表示タイプです。赤/緑のシンタックスハイライト付きでunified diffを描画し、ターミナル出力を暗色のブロックで、ファイル読み取りを行番号付きで表示し、エージェントが触れたすべてのファイルを示すファイルツリーのサイドバーを提供します。アノテーターはファイル間を移動し、長い出力を展開・折りたたみ、個々の操作やトレース全体を評価できます。
設定
プロジェクト設定でコーディングトレース表示を有効にします。
agentic:
enabled: true
trace_converter: claude_code
display_type: coding_trace
coding_trace_display:
# Diff rendering
diff_style: unified # "unified" or "side_by_side"
diff_context_lines: 3 # lines of context around changes
syntax_highlight: true # language-aware highlighting
show_line_numbers: true
# Terminal output
terminal_theme: dark # "dark" or "light"
terminal_max_lines: 80 # auto-collapse after this many lines
show_exit_codes: true
# File reads
file_read_max_lines: 100 # auto-collapse file reads longer than this
show_file_path: true
show_line_range: true # display "lines 42-87" when partial reads
# File tree sidebar
file_tree:
enabled: true
position: left # "left" or "right"
show_operation_icons: true # icons for read/edit/create/delete
group_by_directory: true
click_to_navigate: true # click a file to jump to its operations
# Collapsible sections
auto_collapse_threshold: 500 # characters before auto-collapsing
collapse_file_reads: true
collapse_terminal_output: true表示機能
unified diffビュー
編集操作は赤/緑のハイライト付きのunified diffとして描画されます。削除行は赤の背景と-の接頭辞で、追加行は緑の背景と+の接頭辞で表示されます。コンテキスト行はグレーで表示されます。各diffブロックの上のヘッダーバーには、ファイルパスと行範囲が表示されます。
diff_style: side_by_sideを設定すると、変更前と変更後が隣り合う列に表示され、複雑な編集で何が変わったかを追いやすくなります。
暗色のターミナルブロック
bashやシェルのコマンドは、等幅フォントの暗色のターミナルブロックとして描画されます。コマンド自体は$のプロンプト接頭辞付きで表示され、その下に出力が続きます。終了コードは小さなバッジで表示されます(0なら緑、0以外なら赤)。長い出力は自動的に折りたたまれ、「Show N more lines」の展開ボタンが付きます。
行番号付きのファイル読み取り
エージェントがファイルを読むと、その内容は行番号付きの明色のコードブロックで表示されます。部分的な読み取りでは行範囲が表示されます(例:「lines 42-87 of 312」)。シンタックスハイライトはファイル拡張子に基づいて適用されます。
ファイルツリーのサイドバー
ファイルツリーのサイドバーには、トレース中にエージェントが触れたすべてのファイルが表示されます。ファイルはディレクトリごとにまとめられ、アルファベット順に並びます。各ファイルには、行われた操作を示すアイコンが付きます。
- 鉛筆アイコン:編集されたファイル
- 目のアイコン:読み取りのみのファイル
- プラスアイコン:新規作成されたファイル
- ゴミ箱アイコン:削除されたファイル
- ターミナルアイコン:実行されたスクリプト
ツリー内のファイルをクリックすると、メインパネルがそのファイルに関わる最初の操作までスクロールします。
長い出力の折りたたみ
auto_collapse_thresholdを超える出力ブロックは自動的に折りたたまれます。要約行に最初と最後の数行が表示され、「Show all N lines」ボタンが付きます。これにより、個々の操作が数百行の出力を出す場合でも、トレースをたどりやすい状態が保たれます。
トレースコンバーター
Potatoには、トレース形式を統一的なコーディングトレース表現に正規化する、コーディングエージェント専用のコンバーターが4つ同梱されています。
| コンバーター | 対象 | 形式 |
|---|---|---|
claude_code | Claude Code / Anthropic API | tool_useブロックを含むMessages API(Read、Edit、Bash、Writeの各ツール) |
aider | Aider | SEARCH/REPLACEおよびORIGINAL/UPDATEDの編集ブロックを含むMarkdownのチャットログ |
swe_agent_trajectory | SWE-Agent | thought/action/observationの三つ組を含むトラジェクトリのJSONファイル |
auto | 自動判別 | トレース構造を調べ、最適なコンバーターを自動で選択 |
設定でコンバーターを指定します。
agentic:
trace_converter: claude_code # or aider, swe_agent_trajectory, autoClaude Codeコンバーター
claude_codeコンバーターは、ツール使用がtool_useとtool_resultのコンテンツブロックとして表現されるAnthropic Messages APIのトレースを扱います。Claude Codeの標準ツールを認識します。
- Readのツール呼び出しはファイル読み取りの表示になります
- Editのツール呼び出しはunified diffになります
- Writeのツール呼び出しはファイル作成の表示になります
- Bashのツール呼び出しはターミナルブロックになります
- Glob/Grepのツール呼び出しは検索結果の表示になります
Aiderコンバーター
aiderコンバーターは、AiderのMarkdownベースのチャット形式を解析します。SEARCH/REPLACEブロック(および旧来のORIGINAL/UPDATED形式)を抽出し、unified diffに変換します。シェルコマンドとその出力は、bashまたはshellと指定されたフェンス付きコードブロックから抽出されます。
SWE-Agentトラジェクトリコンバーター
swe_agent_trajectoryコンバーターは、SWE-AgentのトラジェクトリのJSONファイルを読み込みます。トラジェクトリの各エントリには、thought(エージェントの推論)、action(実行されたコマンド)、observation(コマンドの出力)が含まれます。コンバーターはactionをファイル編集、ファイル読み取り、シェルコマンド、ナビゲーション操作に分類します。
CLIの使い方
アノテーションサーバーを起動する前に、生のトレースを変換します。
# Convert Claude Code traces
python -m potato.trace_converter \
-i traces.json \
-f claude_code \
-o data/converted.jsonl
# Convert Aider chat logs
python -m potato.trace_converter \
-i aider_chat_history/ \
-f aider \
-o data/aider_converted.jsonl
# Convert SWE-Agent trajectories
python -m potato.trace_converter \
-i trajectories/ \
-f swe_agent_trajectory \
-o data/swe_converted.jsonl
# Auto-detect format
python -m potato.trace_converter \
-i mixed_traces/ \
-f auto \
-o data/auto_converted.jsonl-iフラグは単一のファイルまたはディレクトリを受け付けます。ディレクトリを指定した場合、.jsonと.jsonlのファイルがすべて処理されます。コンバーターは出力ファイルに1行1JSONオブジェクトで書き出します。
その他のオプション:
# Filter by file extension
python -m potato.trace_converter \
-i traces/ -f claude_code -o data/out.jsonl \
--include "*.json"
# Add metadata fields from a CSV
python -m potato.trace_converter \
-i traces/ -f claude_code -o data/out.jsonl \
--metadata metadata.csv --join-key trace_id
# Validate output without writing
python -m potato.trace_converter \
-i traces.json -f claude_code --validateデータ形式
変換後、出力されるJSONLファイルの各行は次の構造になります。
{
"id": "trace_001",
"task_description": "Fix the failing test in test_parser.py",
"repository": "myproject",
"structured_turns": [
{
"type": "file_read",
"tool": "Read",
"file_path": "src/parser.py",
"content": "def parse(input_str):\n tokens = tokenize(input_str)\n ...",
"line_start": 1,
"line_end": 45
},
{
"type": "edit",
"tool": "Edit",
"file_path": "src/parser.py",
"old_content": " if len(tokens) == 0:\n return None",
"new_content": " if len(tokens) == 0:\n raise ParseError('Empty input')",
"line_start": 12,
"line_end": 13
},
{
"type": "terminal",
"tool": "Bash",
"command": "python -m pytest test_parser.py -v",
"output": "test_parser.py::test_empty_input PASSED\ntest_parser.py::test_valid_input PASSED\n\n2 passed in 0.34s",
"exit_code": 0
},
{
"type": "file_write",
"tool": "Write",
"file_path": "src/parser.py",
"content": "...",
"is_new_file": false
}
],
"metadata": {
"agent": "claude_code",
"model": "claude-sonnet-4-20250514",
"total_tokens": 15234,
"duration_seconds": 42
}
}structured_turnsの配列は操作の順序をそのまま保持します。各ターンにはtypeフィールド(file_read、edit、terminal、file_write、search、thought)と、種類ごとのフィールドがあります。
設定リファレンス
コーディングトレース表示と、コーディングエージェントの出力を評価するためのアノテーションスキーマを組み合わせた完全な設定です。
task_name: "Coding Agent Evaluation"
task_dir: "."
data_files:
- "data/coding_traces.jsonl"
item_properties:
id_key: id
text_key: task_description
agentic:
enabled: true
trace_converter: claude_code
display_type: coding_trace
coding_trace_display:
diff_style: unified
diff_context_lines: 3
syntax_highlight: true
show_line_numbers: true
terminal_theme: dark
terminal_max_lines: 80
show_exit_codes: true
file_read_max_lines: 100
file_tree:
enabled: true
position: left
show_operation_icons: true
group_by_directory: true
click_to_navigate: true
auto_collapse_threshold: 500
annotation_schemes:
# Did the agent complete the task?
- annotation_type: radio
name: task_completion
description: "Did the agent successfully complete the task?"
labels:
- "Fully Complete"
- "Partially Complete"
- "Failed"
- "Made Things Worse"
# Per-step correctness
- annotation_type: per_turn_rating
name: step_quality
description: "Rate this step"
target: agentic_steps
rating_type: radio
labels:
- "Good"
- "Acceptable"
- "Unnecessary"
- "Incorrect"
# Code quality rating
- annotation_type: likert
name: code_quality
description: "Rate the quality of the code changes"
min: 1
max: 5
labels:
1: "Very Poor"
2: "Poor"
3: "Acceptable"
4: "Good"
5: "Excellent"
# Free-text notes
- annotation_type: text
name: notes
description: "Any additional observations about the coding trace"
label_requirement:
required: false
output_annotation_dir: "output/"
output_annotation_format: "jsonl"サンプルプロジェクトの実行
Potatoにはコーディングエージェントアノテーションのサンプルプロジェクトが含まれています。
# Clone the repository
git clone https://github.com/davidjurgens/potato.git
cd potato
# Run the Claude Code trace evaluation example
potato start example/coding_agent_eval/config.yaml -p 8000
# Run the SWE-bench evaluation example
potato start example/swe_bench_eval/config.yaml -p 8000
# Run the multi-agent comparison example
potato start example/coding_agent_comparison/config.yaml -p 8000各サンプルには、サンプルトレース、完全な設定ファイル、アノテーションタスクを説明したREADMEが含まれます。
参考資料
- プロセス報酬アノテーション -- PRM訓練用のステップごとの報酬シグナルの収集
- コードレビューアノテーション -- コード変更に対するGitHub PRスタイルのインラインレビュー
- ライブコーディングエージェント観察 -- コーディングエージェントをリアルタイムで観察し操作する
- エージェント型アノテーション -- 汎用のエージェントトレースアノテーション
- エクスポート形式 -- モデル訓練用のアノテーションデータのエクスポート
実装の詳細については、ソースドキュメントを参照してください。