保留专业Agent回复身份约束

仅对Supervisor final-reply移除重复核心身份
保留普通专业Agent在tool-plan与final-reply上下文中的身份约束
增加普通Agent两条请求路径的回归断言
This commit is contained in:
2026-08-04 18:11:54 +08:00
parent 15a0924d4b
commit b8e3eb4c7f
@@ -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]