From b8e3eb4c7f69a57509a5101c37fcb714f3fe35e8 Mon Sep 17 00:00:00 2001 From: kdletters Date: Tue, 4 Aug 2026 18:11:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E7=95=99=E4=B8=93=E4=B8=9AAgent?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=BA=AB=E4=BB=BD=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 仅对Supervisor final-reply移除重复核心身份 保留普通专业Agent在tool-plan与final-reply上下文中的身份约束 增加普通Agent两条请求路径的回归断言 --- .../provider_request_builders.rs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs index 58363e5ed..c1d521d5e 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/runtime_actions/provider_request_builders.rs @@ -345,10 +345,12 @@ pub(in crate::agent) fn build_game_creator_background_agent_context( )?; let repository_context = build_repository_startup_context_at(root)?; let repository_prompt = render_repository_startup_context_for_prompt(&repository_context); - let identity_instruction = if matches!(mode, AgentBackgroundContextMode::FinalReply) { - "" - } else if template_agent_id == GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID { - game_creator_project_supervisor_identity_contract_prompt() + let identity_instruction = if template_agent_id == GAME_CREATOR_PROJECT_SUPERVISOR_AGENT_ID { + if matches!(mode, AgentBackgroundContextMode::FinalReply) { + "" + } else { + game_creator_project_supervisor_identity_contract_prompt() + } } else { "请只以这个专业 Agent 的身份行动。" }; @@ -731,6 +733,7 @@ mod tests { let ordinary_prompt = &ordinary_request.messages[1].content; assert!(!ordinary_prompt.contains(supervisor_identity_contract)); assert!(ordinary_prompt.contains(ORDINARY_NOTICE)); + assert!(ordinary_prompt.contains("请只以这个专业 Agent 的身份行动")); assert!(!ordinary_prompt.contains(SUPERVISOR_NOTICE)); assert!(!ordinary_prompt.contains(MEMORY_MARKER)); @@ -778,6 +781,21 @@ mod tests { ); assert!(!final_user_prompt.contains(supervisor_identity_contract)); assert!(!final_user_prompt.contains("你拥有最终回复权")); + + let (_, _, ordinary_final_request) = + build_game_creator_agent_background_final_reply_request( + &root, + "code-prototype", + &ordinary_state.session_id, + &ordinary_state.run_id, + &ordinary_state.current_task, + &plan, + &[], + ) + .expect("build ordinary final reply request"); + assert!(ordinary_final_request.messages[1] + .content + .contains("请只以这个专业 Agent 的身份行动")); } #[test]