即時智慧體評估
即時觀看 AI 智慧體工作,並在執行過程中標註其行為,支援暫停、下達指令和接管控制。支援 web 智慧體和編碼智慧體,可選 Anthropic、Ollama 和 Claude SDK。
v2.4.0 新增
即時智慧體評估讓標註者即時看著 AI 智慧體瀏覽網頁,並在它執行的過程中標註它的行為,而不是事後再看。智慧體截圖,把截圖發給視覺 LLM,拿到動作,再在無頭瀏覽器中執行。每一步都即時推送到標註者螢幕上。
環境要求
pip install playwright anthropic
playwright install chromium
export ANTHROPIC_API_KEY=your_key_here配置
live_agent:
endpoint_type: anthropic_vision
ai_config:
model: claude-sonnet-4-20250514
api_key: ${ANTHROPIC_API_KEY}
max_tokens: 4096
temperature: 0.3
system_prompt: |
You are a web browsing agent. Complete the given task efficiently.
At each step, describe your thought, then output an action.
max_steps: 30
step_delay: 1.0
viewport:
width: 1280
height: 720
allow_takeover: true
allow_instructions: true
instance_display:
fields:
- key: task_description
type: text
label: "Task"
- key: agent_trace
type: live_agent
label: "Live Agent Session"
display_options:
show_overlays: true
show_filmstrip: true
show_thought: true
show_controls: true配置參考
| 選項 | 類型 | 預設值 | 說明 |
|---|---|---|---|
endpoint_type | string | anthropic_vision | 智慧體使用的 LLM 提供方 |
ai_config.model | string | claude-sonnet-4-20250514 | 使用的模型 |
ai_config.api_key | string | 環境變數 | API key(用 ${VAR} 語法) |
ai_config.max_tokens | int | 4096 | 每次 LLM 響應的最大 token 數 |
ai_config.temperature | float | 0.3 | 取樣溫度 |
system_prompt | string | 內建 | 智慧體的 system prompt |
max_steps | int | 30 | 停止前的最大步數 |
step_delay | float | 1.0 | 每步之間的間隔秒數 |
viewport.width | int | 1280 | 瀏覽器視口寬度 |
viewport.height | int | 720 | 瀏覽器視口高度 |
allow_takeover | bool | true | 允許標註者手動接管 |
allow_instructions | bool | true | 允許標註者在執行中傳送指令 |
history_window | int | 5 | 納入 LLM 上下文的最近步數 |
資料格式
每條實例提供任務和起始 URL:
{
"id": "task_001",
"task_description": "Search for climate change on Wikipedia and find the year it was first described",
"start_url": "https://en.wikipedia.org"
}標註者工作流程
- 標註者讀完任務描述,點選 Start Agent
- 無頭 Chromium 瀏覽器啟動並連線到 LLM
- 智慧體導航時截圖即時推送到檢視器——每一步顯示截圖、智慧體的想法和採取的動作
- 標註者可以通過控制面板介入:
- Pause / Resume —— 在兩步之間讓智慧體停下
- Send Instructions —— 在執行中往智慧體的上下文裡注入一條訊息
- Take Over —— 切換到手動瀏覽控制
- Stop —— 提前結束會話
- 會話結束時(成功、失敗或達到
max_steps),trace 會被儲存,顯示切換到評審模式 - 標註者填寫標註 schema,評價智慧體的表現
鍵盤快捷鍵
| 按鍵 | 動作 |
|---|---|
Space | 暫停 / 恢復 |
Escape | 結束會話 |
新增標註 schema
即時智慧體顯示可以和任意 Potato 標註 schema 組合:
annotation_schemes:
- annotation_type: radio
name: task_success
description: "Did the agent complete the task?"
labels:
- name: "Yes, fully"
- name: "Partially"
- name: "No"
- annotation_type: likert
name: efficiency
description: "How efficiently did the agent work?"
min_label: "Very inefficient"
max_label: "Very efficient"
- annotation_type: text
name: errors_observed
description: "Describe any errors or unnecessary steps"
- annotation_type: span
name: error_steps
description: "Mark any steps where the agent made an error"
labels:
- name: hallucination
- name: wrong_target
- name: unnecessary_action完整示例
task_name: "Live Agent Evaluation Study"
task_dir: "."
live_agent:
endpoint_type: anthropic_vision
ai_config:
model: claude-sonnet-4-20250514
api_key: ${ANTHROPIC_API_KEY}
max_tokens: 4096
temperature: 0.3
max_steps: 25
step_delay: 1.5
viewport:
width: 1280
height: 720
allow_takeover: true
allow_instructions: true
history_window: 5
data_files:
- "tasks.jsonl"
instance_display:
fields:
- key: task_description
type: text
label: "Task"
- key: agent_trace
type: live_agent
label: "Live Session"
display_options:
show_overlays: true
show_filmstrip: true
show_thought: true
show_controls: true
annotation_schemes:
- annotation_type: radio
name: task_success
description: "Did the agent complete the task?"
labels:
- name: "Yes"
- name: "Partially"
- name: "No"
- annotation_type: likert
name: efficiency
description: "Rate the agent's efficiency"
min_label: "Very inefficient"
max_label: "Very efficient"
- annotation_type: text
name: notes
description: "Notes on agent behavior"
output_annotation_dir: "output/"
output_annotation_format: "jsonl"架構
即時智慧體作為 Flask 中的後臺執行緒執行。截圖和狀態變化通過 Server-Sent Events(SSE)推送到瀏覽器。標註者的控制操作(暫停、下達指令、接管、停止)呼叫 REST 介面,與後臺執行緒同步。
Annotator (browser) <── SSE stream ── Flask Server ── Playwright ──► Headless Browser
──► REST control ─► ◄── LLM API ────► Claude Vision
截圖儲存在 {task_dir}/live_sessions/,並通過 API 提供給膠片條檢視。
Trace 匯出
會話結束後,Potato 會自動把完整 trace 匯出為相容 web_agent_trace 的 JSON,內容包括:
- 所有步驟,含截圖、動作、想法和觀察
- 標註者在執行中傳送的任何指令
- 時間戳和智慧體配置的後設資料
- 標註者的接管事件
也就是說,已完成的即時會話之後可以用標準的 Web 智慧體標註檢視器來回看。
故障排查
「Playwright is not installed」 —— 執行 pip install playwright && playwright install chromium。
「Anthropic API key required」 —— 設定 ANTHROPIC_API_KEY 環境變數,或在配置中使用 api_key: ${ANTHROPIC_API_KEY}。
智慧體好像很慢 —— 每一步都需要一次 LLM API 呼叫(通常 3–10 秒)。LLM 處理期間會顯示思考指示器。把 history_window 調小可以加快長會話。
截圖載入不出來 —— 檢查 task_dir 是否可寫,以及伺服器磁碟空間是否夠用。
編碼智慧體後端
除了網頁瀏覽智慧體,Potato 也支援即時觀察編碼智慧體。有三種後端可選:
Ollama(本地,無需 API key)
用完全本地的模型做編碼智慧體評估,不需要 API key。
live_agent:
endpoint_type: coding_agent
backend: ollama
ai_config:
model: qwen2.5-coder:7b
host: "http://localhost:11434"
max_steps: 50
project_dir: "./workspace"Anthropic API
用帶工具使用的 Claude 做編碼智慧體評估。
live_agent:
endpoint_type: coding_agent
backend: anthropic
ai_config:
model: claude-sonnet-4-20250514
api_key: ${ANTHROPIC_API_KEY}
max_tokens: 8192
max_steps: 50
project_dir: "./workspace"Claude Agent SDK
為進階的編碼智慧體會話提供完整的 Claude Code 能力。
live_agent:
endpoint_type: coding_agent
backend: claude_agent_sdk
ai_config:
max_turns: 50
project_dir: "./workspace"完整參考(包括回滾、分支和軌跡匯出)見即時編碼智慧體。
回滾與檢查點
對編碼智慧體會話,Potato 會在每次檔案改動之後建立一個 git 提交。由此可以做到:
- 一鍵回滾到之前的任意檢查點
- 分支與重放 —— 從任意檢查點換一種思路重來
- 每個檔案狀態的完整歷史,供評審檢視
檢查點通過每個會話專屬的 git 分支自動管理。
分支軌跡
標註者回滾並嘗試另一種做法時,Potato 會建立一條分支軌跡。兩條分支都保留在輸出中,產出的訓練資料可用於:
- 過程獎勵模型 —— 跨分支的步級正確性標籤
- 偏好學習 —— 哪條分支產生了更好的結果
- 程式碼評審資料集 —— 比較不同做法的程式碼品質
延伸閱讀
- 即時編碼智慧體 —— 用 Ollama、Anthropic 和 Claude SDK 觀察編碼智慧體
- Web 智慧體標註 —— 評審預先錄製的智慧體 trace
- 智慧體標註 —— 智慧體 trace 格式與轉換器概覽
- 過程獎勵標註 —— PRM 訓練資料收集
- AI 輔助 —— 用於標註輔助的 LLM 整合
有關實現詳情,請參閱源文件。