From a2e6f205d660cfa8a2b2b6e0104bf991021d3d58 Mon Sep 17 00:00:00 2001 From: Linghong Date: Fri, 18 Sep 2026 04:55:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=80=E7=BB=88=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=A4=B1=E8=B4=A5=E6=B5=8B=E8=AF=95=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最终回复失败测试显式关闭 Provider 重试 让非法回复 mock 按实际请求次数监听 同步运行态公共失败审计测试的 mock 参数 --- apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs | 10 ++++------ .../src-tauri/src/tests/runtime_state.rs | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs index a91336e16..6f5317d98 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs @@ -1576,6 +1576,7 @@ pub(crate) fn spawn_mock_llm_server_responses(response_contents: Vec) -> pub(crate) fn spawn_mock_llm_tool_plan_then_invalid_final_reply( planning_response: String, + final_reply_requests: usize, ) -> String { let listener = bind_test_tcp_listener("mock invalid final reply bind"); let base_url = format!("http://{}", listener.local_addr().expect("mock llm addr")); @@ -1617,11 +1618,7 @@ pub(crate) fn spawn_mock_llm_tool_plan_then_invalid_final_reply( .write_all(planning_response.as_bytes()) .expect("mock tool plan response"); - // Autonomous runs enforce a 12-retry floor. Return the same malformed - // response for the initial final-reply request and every retry so this - // fixture tests deserialize exhaustion rather than an accidental - // connection-refused fallback after the first malformed response. - for _ in 0..=12 { + for _ in 0..final_reply_requests.max(1) { let (mut final_stream, _) = listener.accept().expect("mock final reply accept"); drop(read_mock_http_request(&mut final_stream)); let invalid_body = "{invalid-json"; @@ -5934,7 +5931,7 @@ async fn background_agent_runtime_marks_response_plan_step_failed_when_final_rep "response": "" }) .to_string(); - let base_url = spawn_mock_llm_tool_plan_then_invalid_final_reply(plan_json); + let base_url = spawn_mock_llm_tool_plan_then_invalid_final_reply(plan_json, 1); let _config_guard = write_test_local_config(format!( r#"{{ "agentLlm": {{ @@ -5943,6 +5940,7 @@ async fn background_agent_runtime_marks_response_plan_step_failed_when_final_rep "baseUrl": {base_url:?}, "model": "design-runtime-model", "apiKind": "openai_responses", + "maxRetries": 0, "retryBackoffMs": 1 }} }} diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/runtime_state.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/runtime_state.rs index 88db4e255..9515a6e4a 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/runtime_state.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/runtime_state.rs @@ -1147,7 +1147,7 @@ async fn background_final_reply_failure_keeps_private_conversation_and_hashes_pu "response": "" }) .to_string(); - let base_url = spawn_mock_llm_tool_plan_then_invalid_final_reply(planning_response); + let base_url = spawn_mock_llm_tool_plan_then_invalid_final_reply(planning_response, 1); replace_test_local_config( &config_path, format!( -- 2.52.0