feat(runtime): observe turn evidence without changing execution controls
This commit is contained in:
@@ -89,3 +89,10 @@
|
||||
.checkpoint-assessment ul { margin: 8px 0; padding-left: 18px; overflow-wrap: anywhere; }
|
||||
.checkpoint-assessment .button, .task-checkpoints > .button { margin-top: 8px; height: auto; min-height: 36px; white-space: normal; }
|
||||
@media (max-width: 620px) { .task-checkpoints .button, .task-checkpoints .text-button { min-height: 44px; } }
|
||||
.turn-progress { margin-top: 14px; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
|
||||
.turn-progress summary { cursor: pointer; color: #154b4a; font-weight: 600; }
|
||||
.turn-progress ol { list-style: none; padding: 0; margin: 10px 0; }
|
||||
.turn-progress li { border-top: 1px solid #dce7e2; padding: 10px 0; }
|
||||
.turn-progress li strong { font-size: 12px; }
|
||||
.turn-progress li p { margin: 4px 0; }
|
||||
@media (max-width: 620px) { .turn-progress .text-button { min-height: 44px; } }
|
||||
|
||||
@@ -10,6 +10,7 @@ import { WorkspacePanel } from './WorkspacePanel';
|
||||
import { BrowserPanel } from './BrowserPanel';
|
||||
import { TaskPlanPanel } from './TaskPlanPanel';
|
||||
import { RequirementPanel } from './RequirementPanel';
|
||||
import { TurnProgress } from './TurnProgress';
|
||||
import { TaskCheckpointPanel } from './TaskCheckpointPanel';
|
||||
import { McpJobHistory } from './McpJobHistory';
|
||||
import './TaskPanel.css';
|
||||
@@ -116,6 +117,7 @@ export function TaskPanel({ project, session, onSession, onError, busy, onWorksp
|
||||
<dt>本次预算</dt><dd>{number(run.budget?.maxTokens)} tokens · {Math.round((run.budget?.maxDurationMs ?? 0) / 60000)} 分钟 · {run.budget?.maxSteps} 轮</dd><dt>任务累计</dt><dd>{number(execution?.accountedTaskTokens)} / {number(task.budget.maxTokens)} tokens</dd>
|
||||
</dl>{run.stopReason && <p className="run-stop">{stopReasons[run.stopReason] || run.stopReason}</p>}
|
||||
<p className="record-footnote">用量按请求尝试累计,包含失败响应已报告的 tokens;未报告的请求单独估算。历史缺失不补造,tokens 不等于费用。</p>
|
||||
<TurnProgress run={run} openArtifact={openArtifact} />
|
||||
</> : <p className="record-empty"><LoaderCircle size={14} className="spin" />正在读取运行记录</p>}
|
||||
</section>}
|
||||
{run && <RequestContextPanel session={session} runId={run.id} onError={onError} openArtifact={openArtifact} />}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { Run } from './types';
|
||||
const labels: Record<string, string> = { baseline: '本次运行基线', waiting: '等待所属操作', evidence_growth: '新增外显证据', new_failure_evidence: '新增失败证据',
|
||||
user_boundary: '用户边界变化', repeated_failure_candidate: '重复失败候选', repeated_read_candidate: '重复读取候选', no_observed_change: '未见新外显事实', unknown_bounded: '观察容量已满,保留未知' };
|
||||
const failureLabels: Record<string, string> = { invalid_input: '参数无效', permission: '权限或审批拒绝', requires_verification: '结果待核对', network: '网络连接', service: '上游服务',
|
||||
authentication: '身份验证', rate_limit: '请求限流', quota: '服务额度', tool_or_environment: '工具或环境', unknown: '尚未分类' };
|
||||
export function TurnProgress({ run, openArtifact }: { run: Run; openArtifact: (id: string) => void }) {
|
||||
if (!run.progressShadow && !run.progressShadowError) return null;
|
||||
const shadow = run.progressShadow;
|
||||
return <details className="turn-progress" aria-label="单轮观察">
|
||||
<summary>单轮观察 · 仅记录{shadow ? ` · 已保留 ${shadow.turns.filter(row => row.phase === 'settled').length} 轮` : ''}</summary>
|
||||
<p className="record-footnote">依据实际工具、文件范围、失败和证据变化分类;观察不改变停止、权限或预算。</p>
|
||||
{run.progressShadowError && <p className="plan-problem">部分观察未能记录,原工具结果保留。</p>}
|
||||
{shadow?.truncated && <p className="record-footnote">观察已达保留上限;较早收据仍在原工件中,未保留范围不推定为重复。</p>}
|
||||
<ol>{shadow?.turns.map((turn, index) => <li key={`${turn.stepId}/${turn.phase}/${index}`}>
|
||||
<strong>{turn.stepIndex === null ? '基线' : `第 ${turn.stepIndex} 轮`} · {labels[turn.classification] ?? turn.classification}</strong>
|
||||
<p>新增读取 {turn.delta.read_characters} 字符 · 重复读取 {turn.delta.repeated_reads} 次{turn.delta.changed_files ? ` · 改动文件 ${turn.delta.changed_files}` : ''}{turn.delta.check_results ? ` · 检查结果 ${turn.delta.check_results}` : ''}{turn.delta.requirement_evidence ? ` · 要求证据 ${turn.delta.requirement_evidence}` : ''}</p>
|
||||
{!!(turn.delta.new_failures || turn.delta.repeated_failures) && <p>新失败 {turn.delta.new_failures} · 重复失败 {turn.delta.repeated_failures}</p>}
|
||||
{turn.reasons.some(reason => /^(new|repeated)_failure:/.test(reason)) && <p>失败类别:{[...new Set(turn.reasons.filter(reason => /^(new|repeated)_failure:/.test(reason)).map(reason => {
|
||||
const kind = reason.split(':')[1]; return failureLabels[kind] ?? kind;
|
||||
}))].join('、')}</p>}
|
||||
{!!turn.waiting.length && <p>等待 {turn.waiting.map(row => ({ approval: '审批', check_job: '检查作业', review: '审查' }[row.kind] ?? row.kind)).join('、')}</p>}
|
||||
{run.progressShadowArtifactIds?.[index] && <button className="text-button" onClick={() => openArtifact(run.progressShadowArtifactIds![index])}>查看原观察收据</button>}
|
||||
</li>)}</ol>
|
||||
</details>;
|
||||
}
|
||||
@@ -142,6 +142,12 @@ export interface Usage { requests: number; inputTokens: number; outputTokens: nu
|
||||
export interface RunBudget { maxSteps: number; maxDurationMs: number; maxTokens: number; maxTaskTokens: number }
|
||||
export interface RunBrief { id: string; taskId: string; status: string; startedAt: string; finishedAt: string | null; steps: number; toolCalls: number; usage: Usage; stopReason: string | null; model: ModelSnapshot; budget: RunBudget; resumeOf: string | null; workspaceIdentity?: WorkspaceIdentity }
|
||||
export interface Run extends RunBrief { engine: string; review?: { kind: string; planId: string; status: string; preparedAt?: string; resolvedAt?: string }; currentContextPlanId?: string; checkpoint: { completedToolIds: string[]; pendingToolIds: string[]; requiresVerification: string[] } }
|
||||
export interface TurnObservation {
|
||||
stepId: string | null; stepIndex: number | null; phase: string; classification: string; reasons: string[]; truncated: boolean;
|
||||
delta: { read_characters: number; repeated_reads: number; changed_files: number; check_results: number; requirement_evidence: number; new_failures: number; repeated_failures: number };
|
||||
waiting: { kind: string; id: string }[];
|
||||
}
|
||||
export interface Run { progressShadow?: { mode: 'shadow'; observations: number; truncated: boolean; turns: TurnObservation[] }; progressShadowArtifactIds?: string[]; progressShadowError?: { kind: string; phase: string } }
|
||||
export interface RunBrief { purpose?: 'execution' | 'diagnostic'; source?: string; taskStatusBefore?: string; consumption?: ModelConsumption[] }
|
||||
export interface TaskCheckpoint {
|
||||
id: string; sessionId: string; projectId: string; taskId: string; runId: string; createdAt: string;
|
||||
|
||||
Reference in New Issue
Block a user