From cb43b2871bfefe0b38436f6fa3da652e3532f850 Mon Sep 17 00:00:00 2001 From: hy Date: Thu, 24 Sep 2026 16:45:00 +0800 Subject: [PATCH] refactor: remove fallbackCode from terminal review types and related logic --- doc/ai-harness/human-harness.md | 2 +- .../ai/human/node/handNode/terminalReview.ts | 16 +++++----------- src/shared/types.ts | 1 - .../ai/tool/hand/hand-terminal-ai-review.test.ts | 10 ---------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/doc/ai-harness/human-harness.md b/doc/ai-harness/human-harness.md index 13597220..d5d4f69a 100644 --- a/doc/ai-harness/human-harness.md +++ b/doc/ai-harness/human-harness.md @@ -132,7 +132,7 @@ append-only 伙伴消息转录;模型上下文、UI、resume 均由此投影 | `compaction_checkpoint` | `{ compactBlockId, throughSeq, sourceMessageCount, summary }` | 压缩书签 + 摘要正文;`seq <= historyFloorSeq` 的原文不再进 brain;发给主模型时再合成 Compact User | | `finalizing_started` | `{}` | 投影时**清空** plan | | `human_interaction_resolved` | `{ interactionId, kind, result }` | UI Activity:在对应工具行下按顺序展示问题答案或审批结果 | -| `terminal_review_resolved` | `{ reviewId, decisions: [{ commandId, decision }], fallbackCode? }` | `terminal_run` 副作用命中后的 AI 审核结论;命令编号对应 hand 批次中的 toolCallId;格式或调用失败时记录 fallbackCode | +| `terminal_review_resolved` | `{ reviewId, decisions: [{ commandId, decision }] }` | `terminal_run` 副作用命中后的 AI 审核结论;命令编号对应 hand 批次中的 toolCallId | #### `entry_json` 示例 diff --git a/src/main/services/ai/human/node/handNode/terminalReview.ts b/src/main/services/ai/human/node/handNode/terminalReview.ts index 4f547d72..4e8db3d4 100644 --- a/src/main/services/ai/human/node/handNode/terminalReview.ts +++ b/src/main/services/ai/human/node/handNode/terminalReview.ts @@ -18,7 +18,6 @@ export type TerminalReviewDecision = { export type TerminalReviewResult = { decisions: TerminalReviewDecision[] - fallbackCode?: 'invalid_output' | 'review_unavailable' } const MAX_OUTPUT_RETRIES = 3 @@ -36,15 +35,11 @@ const reviewSchema = z }) .strict() -const humanFallback = ( - commands: readonly TerminalReviewCandidate[], - fallbackCode: TerminalReviewResult['fallbackCode'] -): TerminalReviewResult => ({ +const humanFallback = (commands: readonly TerminalReviewCandidate[]): TerminalReviewResult => ({ decisions: commands.map((command) => ({ commandId: command.commandId, decision: 'needs_human_review' - })), - ...(fallbackCode ? { fallbackCode } : {}) + })) }) const matchDecisions = ( @@ -103,12 +98,12 @@ export const reviewTerminalCommands = async (input: { if (isCancelledError(error)) throw error input.ctx.checkCancelled() if (!isLlmOutputError(error)) { - return humanFallback(input.commands, 'review_unavailable') + return humanFallback(input.commands) } } } - return humanFallback(input.commands, 'invalid_output') + return humanFallback(input.commands) } export const buildTerminalReviewAnnotation = (input: { @@ -119,7 +114,6 @@ export const buildTerminalReviewAnnotation = (input: { eventType: 'terminal_review_resolved', payload: { reviewId: input.reviewId, - decisions: input.result.decisions, - ...(input.result.fallbackCode ? { fallbackCode: input.result.fallbackCode } : {}) + decisions: input.result.decisions } }) diff --git a/src/shared/types.ts b/src/shared/types.ts index 60c96dc7..a07b5763 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -2016,7 +2016,6 @@ export type ChatMessageLogAnnotationEntry = commandId: string decision: 'auto_approve' | 'needs_human_review' }> - fallbackCode?: 'invalid_output' | 'review_unavailable' } } | { diff --git a/tests/case/ai/tool/hand/hand-terminal-ai-review.test.ts b/tests/case/ai/tool/hand/hand-terminal-ai-review.test.ts index b002d18c..7bd6c9a3 100644 --- a/tests/case/ai/tool/hand/hand-terminal-ai-review.test.ts +++ b/tests/case/ai/tool/hand/hand-terminal-ai-review.test.ts @@ -315,17 +315,9 @@ describe('ai tool hand terminal review', () => { } }) const output = await runner.run({ taskId: runtime.taskId, userInput: '请处理目录。' }) - const records = await runner.ctx.loadMessageLog() - const fallbackCodes = records.flatMap((record) => { - const { entry } = record - return entry.kind === 'annotation' && entry.eventType === 'terminal_review_resolved' - ? [entry.payload.fallbackCode] - : [] - }) return { output, reviewCallCount, - fallbackCodes, exists: await fs .stat(target) .then(() => true) @@ -337,8 +329,6 @@ describe('ai tool hand terminal review', () => { runtime.assertThat( result.output.status === 'completed' && result.reviewCallCount === 4 && - result.fallbackCodes.length === 1 && - result.fallbackCodes[0] === 'invalid_output' && !result.exists && filterAiRunEventsByType(result.events, 'approval_batch_required').length === 1 && filterAiRunEventsByType(result.events, 'terminal_step_started').length === 0,