diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/delivery.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/delivery.rs index 709023e9d..5e2d6b790 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/delivery.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_tools/delivery.rs @@ -134,11 +134,7 @@ pub(crate) fn build_static_delegate_result_for_child_at( .as_deref() .or((!result_detail.trim().is_empty()).then_some(result_detail)); let result_detail = result_detail.map(|value| { - redact_agent_runtime_error( - root, - value, - static_delegate_result_detail_max_chars(value, 500), - ) + truncate_agent_runtime_text(value, static_delegate_result_detail_max_chars(value, 500)) }); let mut result = build_static_delegate_structured_result_at( root, @@ -923,8 +919,8 @@ pub(crate) fn publish_game_creator_agent_delegate_result( .or(child_task.terminal_detail.as_deref()) .or(child_task.error.as_deref()) .unwrap_or(child_task.current_action.as_str()); - let result_detail = redact_agent_runtime_error( - root, + // 给父 run 看的结果原文:不脱敏、不截断路径,只做长度上限。 + let result_detail = truncate_agent_runtime_text( raw_result_detail, static_delegate_result_detail_max_chars(raw_result_detail, 600), ); @@ -1112,8 +1108,8 @@ pub(crate) fn publish_game_creator_agent_delegate_result( if receipt_exists { return; } - let receipt_result_detail = sanitize_agent_runtime_text( - &sanitize_prompt_context(raw_result_detail), + let receipt_result_detail = truncate_agent_runtime_text( + raw_result_detail, static_delegate_result_detail_max_chars(raw_result_detail, 600), ); let receipt_task = format!( @@ -1155,11 +1151,11 @@ pub(crate) fn publish_game_creator_agent_delegate_result( parent_agent_id: None, parent_run_id: Some(parent_run_id.to_string()), delegation_id: Some(delegation_id.to_string()), - task: sanitize_agent_runtime_text(&receipt_task, 180), + task: truncate_agent_runtime_text(&receipt_task, 180), status: "cancelled".to_string(), phase: "parent-terminal".to_string(), current_action: "父任务已取消或失败,回执仅保留审计,不自动续跑".to_string(), - terminal_detail: Some(sanitize_agent_runtime_text(&result_detail, 500)), + terminal_detail: Some(truncate_agent_runtime_text(&result_detail, 500)), error: None, updated_at: unix_timestamp(), }; @@ -1238,6 +1234,12 @@ pub(in crate::agent) fn record_game_creator_agent_delegate_result_success( receipt_status: &str, result_detail: &str, ) { + // 审计记录自己脱敏;给父 run 的回执用原文。 + let result_preview = redact_agent_runtime_error( + root, + result_detail, + static_delegate_result_detail_max_chars(result_detail, 600), + ); let event_state = agent_runtime_state_from_task_record(child_task); let _ = append_game_creator_agent_runtime_event( root, @@ -1264,7 +1266,7 @@ pub(in crate::agent) fn record_game_creator_agent_delegate_result_success( "status": terminal_status, "receiptRunId": receipt_run_id, "receiptStatus": receipt_status, - "resultPreview": result_detail, + "resultPreview": result_preview, }), ); } @@ -1528,7 +1530,7 @@ pub(in crate::agent) fn observe_agent_runtime_schedule_ready_tasks( status: "ok".to_string(), summary: format!("已调度 {} 个 Ready 任务", results.len()), detail: Some(truncate_agent_runtime_text( - sanitize_prompt_context(&detail).as_str(), + &detail, AGENT_RUNTIME_TOOL_OBSERVATION_MAX_CHARS, )), } @@ -1536,7 +1538,7 @@ pub(in crate::agent) fn observe_agent_runtime_schedule_ready_tasks( Err(error) => AgentRuntimeToolObservation { tool: "agent.schedule_ready".to_string(), status: "failed".to_string(), - summary: redact_agent_runtime_project_paths(root, &error, 240), + summary: truncate_agent_runtime_text(&error, 240), detail: None, }, }