给 ui-design-doc 三个观察的 rejected 摘要统一脱敏
agent/runtime_tools/ui_design_doc.rs 让 rejected 接收项目根并复用 redact_agent_runtime_project_paths:项目上下文缺失时的报错会带上宿主路径,原先把 rejected 当成「只含模型参数」直接透出,摘要会泄露绝对路径
This commit is contained in:
@@ -35,11 +35,11 @@ pub(in crate::agent) fn observe_agent_runtime_ui_design_doc_from_images(
|
||||
let tool = UI_DESIGN_DOC_FROM_IMAGES_TOOL;
|
||||
let arguments = match serde_json::from_value::<FromImagesArguments>(input.clone()) {
|
||||
Ok(arguments) => arguments,
|
||||
Err(error) => return rejected(tool, format!("{tool} 输入无效:{error}")),
|
||||
Err(error) => return rejected(root, tool, format!("{tool} 输入无效:{error}")),
|
||||
};
|
||||
let expected_project_id = match game_creator_agent_runtime_context_project_id(root) {
|
||||
Ok(project_id) => project_id,
|
||||
Err(error) => return rejected(tool, error),
|
||||
Err(error) => return rejected(root, tool, error),
|
||||
};
|
||||
let revision_before = read_game_creator_agent_runtime_project_revision(root)
|
||||
.ok()
|
||||
@@ -83,11 +83,11 @@ pub(in crate::agent) async fn observe_agent_runtime_ui_design_doc_run_workflow(
|
||||
let tool = UI_DESIGN_DOC_RUN_WORKFLOW_TOOL;
|
||||
let arguments = match serde_json::from_value::<DesignDocArguments>(input.clone()) {
|
||||
Ok(arguments) => arguments,
|
||||
Err(error) => return rejected(tool, format!("{tool} 输入无效:{error}")),
|
||||
Err(error) => return rejected(root, tool, format!("{tool} 输入无效:{error}")),
|
||||
};
|
||||
let expected_project_id = match game_creator_agent_runtime_context_project_id(root) {
|
||||
Ok(project_id) => project_id,
|
||||
Err(error) => return rejected(tool, error),
|
||||
Err(error) => return rejected(root, tool, error),
|
||||
};
|
||||
let revision_before = read_game_creator_agent_runtime_project_revision(root)
|
||||
.ok()
|
||||
@@ -142,11 +142,11 @@ pub(in crate::agent) fn observe_agent_runtime_ui_design_doc_into_js(
|
||||
let tool = UI_DESIGN_DOC_INTO_JS_TOOL;
|
||||
let arguments = match serde_json::from_value::<DesignDocArguments>(input.clone()) {
|
||||
Ok(arguments) => arguments,
|
||||
Err(error) => return rejected(tool, format!("{tool} 输入无效:{error}")),
|
||||
Err(error) => return rejected(root, tool, format!("{tool} 输入无效:{error}")),
|
||||
};
|
||||
let expected_project_id = match game_creator_agent_runtime_context_project_id(root) {
|
||||
Ok(project_id) => project_id,
|
||||
Err(error) => return rejected(tool, error),
|
||||
Err(error) => return rejected(root, tool, error),
|
||||
};
|
||||
match generate_ui_design_code_at(GenerateUiDesignCodeInput {
|
||||
project_path: root.to_string_lossy().into_owned(),
|
||||
@@ -166,12 +166,12 @@ pub(in crate::agent) fn observe_agent_runtime_ui_design_doc_into_js(
|
||||
}
|
||||
}
|
||||
|
||||
/// 输入解析失败:模型只给了参数,摘要里不含宿主路径,无需再脱敏。
|
||||
fn rejected(tool: &str, summary: String) -> AgentRuntimeToolObservation {
|
||||
/// 输入解析失败或项目上下文缺失:统一脱敏,避免摘要把宿主路径带给 provider。
|
||||
fn rejected(root: &Path, tool: &str, summary: String) -> AgentRuntimeToolObservation {
|
||||
AgentRuntimeToolObservation {
|
||||
tool: tool.to_string(),
|
||||
status: "rejected".to_string(),
|
||||
summary,
|
||||
summary: redact_agent_runtime_project_paths(root, &summary, 240),
|
||||
detail: None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user