From 6af95b8a226455afbe9614f8c381262141d6c4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 1 Oct 2026 18:28:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E3=80=8C=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=9B=9E=E6=89=A7=E8=BF=9B=20message=20=E5=89=8D=E5=85=88?= =?UTF-8?q?=E6=8C=89=E5=90=84=E8=87=AA=E9=A2=84=E7=AE=97=E5=81=9A=E6=9C=89?= =?UTF-8?q?=E7=95=8C=E5=BA=8F=E5=88=97=E5=8C=96=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 撤销 004889f27:给模型的工具结果不做任何截断,报告原文完整回给模型 - 撤销 tool/error.rs 的 bounded_report_text 及 browser_playtest / cocos_execute / environment_check / editor_execute 四处调用 - 截断与脱敏只保留在诊断/审计侧(persist_agent_runtime_error) --- .../src-tauri/src/agent/tool/browser_playtest/error.rs | 9 ++------- .../src-tauri/src/agent/tool/cocos_execute/error.rs | 9 ++------- .../src-tauri/src/agent/tool/editor_execute/error.rs | 10 ++-------- .../src/agent/tool/environment_check/error.rs | 9 ++------- .../src-tauri/src/agent/tool/error.rs | 9 --------- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/browser_playtest/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/browser_playtest/error.rs index 783dad21c..55291cfda 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/browser_playtest/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/browser_playtest/error.rs @@ -2,7 +2,7 @@ //! //! 这里只放错误本身;参数解析与工具执行留在 `direct_tool_bridge` 与 `direct_validation`。 -use crate::agent::tool::error::{bounded_report_text, ToolFailure}; +use crate::agent::tool::error::ToolFailure; use serde_json::Value; /// `agc_browser_playtest` 的每一种失败各占一个变体;文案写在这里,捕获处只调 `to_user_msg`。 @@ -25,12 +25,7 @@ impl ToolFailure for BrowserPlaytestError { fn to_user_msg(&self) -> String { match self { Self::PlaytestFailed { cause } => cause.to_string(), - Self::PlaytestNotPassed { report, .. } => { - format!( - "浏览器试玩未通过:{}", - bounded_report_text(report, self.redact_limit()) - ) - } + Self::PlaytestNotPassed { report, .. } => format!("浏览器试玩未通过:{report}"), } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/cocos_execute/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/cocos_execute/error.rs index 1ae4cb232..b0146f279 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/cocos_execute/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/cocos_execute/error.rs @@ -2,9 +2,7 @@ //! //! 这里只放错误本身;参数解析与工具执行留在 `direct_tool_bridge`。 -use crate::agent::tool::error::{ - bounded_report_text, ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure, -}; +use crate::agent::tool::error::{ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure}; use serde_json::Value; /// Cocos 执行工具的每一种失败各占一个变体;文案写在这里,捕获处只调 `to_user_msg`。 @@ -79,10 +77,7 @@ impl ToolFailure for CocosExecuteError { .to_string() } Self::ExecutionNotCompleted { report, .. } => { - format!( - "Cocos 执行未完成:{}", - bounded_report_text(report, self.redact_limit()) - ) + format!("Cocos 执行未完成:{report}") } } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/editor_execute/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/editor_execute/error.rs index 197b99344..55e0f0138 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/editor_execute/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/editor_execute/error.rs @@ -2,9 +2,7 @@ //! //! 这里只放错误本身;参数解析与工具执行留在 `direct_tool_bridge`。 -use crate::agent::tool::error::{ - bounded_report_text, ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure, -}; +use crate::agent::tool::error::{ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure}; use serde_json::Value; /// `code` 的长度上限(字节):编辑器适配器按 UTF-8 字节数收代码。 @@ -108,11 +106,7 @@ impl ToolFailure for EditorExecuteError { } => format!("code 有 {got_bytes} 字节,超过上限 {max_bytes} 字节。"), Self::EditorRejected { cause } => cause.to_string(), Self::ExecutionNotCompleted { editor, report } => { - format!( - "{} 执行未完成:{}", - editor.label(), - bounded_report_text(report, self.redact_limit()) - ) + format!("{} 执行未完成:{report}", editor.label()) } Self::ExecutionUnconfirmed { editor } => format!( "{} 执行任务异常,回执不可用;执行已发出,结果待核对,不要自动重放:\ diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/environment_check/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/environment_check/error.rs index 31afb63ae..8095c054c 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/environment_check/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/environment_check/error.rs @@ -2,9 +2,7 @@ //! //! 这里只放错误本身;参数解析与工具执行留在 `direct_tool_bridge`。 -use crate::agent::tool::error::{ - bounded_report_text, ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure, -}; +use crate::agent::tool::error::{ProjectPermissionRejection, ToolArgumentsRejection, ToolFailure}; use serde_json::Value; /// `agc_environment_check` 不接受任何参数,所以它自己的失败只有权限门禁与环境未就绪两类。 @@ -35,10 +33,7 @@ impl ToolFailure for EnvironmentCheckError { match self { Self::Arguments(rejection) => rejection.to_user_msg(), Self::PermissionDenied(rejection) => rejection.to_user_msg(), - Self::EnvironmentNotReady { report } => format!( - "本地环境未就绪:{}", - bounded_report_text(report, self.redact_limit()) - ), + Self::EnvironmentNotReady { report } => format!("本地环境未就绪:{report}"), } } diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/error.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/error.rs index 2c1ada9ab..43f9ee47f 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/tool/error.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/tool/error.rs @@ -17,15 +17,6 @@ pub(crate) fn bounded_echo(text: &str) -> String { crate::agent::runtime_state::truncate_agent_runtime_text(text, BOUNDED_ECHO_MAX_CHARS) } -/// 工具回执一类的 JSON 载荷落进 message 前的有界序列化。 -/// -/// [`ToolFailure::to_user_msg`] 的结果之后还要过整条脱敏流水线,最后才按 -/// [`ToolFailure::redact_limit`] 截断;先按同一预算截一次,避免整份大载荷在多趟脱敏里 -/// 被反复搬运。 -pub(crate) fn bounded_report_text(value: &Value, max_chars: usize) -> String { - crate::agent::runtime_state::truncate_agent_runtime_text(&value.to_string(), max_chars) -} - /// `sourceLocalAssetId` 不在当前项目 manifest 时的完整指引:模型要知道下一步做什么, /// 只报「不属于已登记资源」会让它原地重试。 ///