fix: restore zhihu ws routing before direct submit
Keep ws-backed submit flows routing Zhihu natural-language requests through orchestration before direct submit so sg_claw service console behavior stays consistent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,7 @@ fn write_config(
|
||||
model: &str,
|
||||
skills_dir: Option<&str>,
|
||||
browser_ws_url: Option<&str>,
|
||||
direct_submit_skill: Option<&str>,
|
||||
) -> PathBuf {
|
||||
let config_path = root.join("sgclaw_config.json");
|
||||
let mut payload = json!({
|
||||
@@ -52,6 +53,9 @@ fn write_config(
|
||||
if let Some(browser_ws_url) = browser_ws_url {
|
||||
payload["browserWsUrl"] = json!(browser_ws_url);
|
||||
}
|
||||
if let Some(direct_submit_skill) = direct_submit_skill {
|
||||
payload["directSubmitSkill"] = json!(direct_submit_skill);
|
||||
}
|
||||
fs::write(&config_path, serde_json::to_string_pretty(&payload).unwrap()).unwrap();
|
||||
config_path
|
||||
}
|
||||
@@ -726,6 +730,76 @@ fn direct_skill_mode_logs_direct_skill_primary() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn production_submit_task_with_ws_and_direct_submit_config_routes_zhihu_before_direct_submit() {
|
||||
let _guard = env_lock().lock().unwrap_or_else(|err| err.into_inner());
|
||||
std::env::set_var("SGCLAW_DISABLE_POST_EXPORT_OPEN", "1");
|
||||
std::env::remove_var("DEEPSEEK_API_KEY");
|
||||
std::env::remove_var("DEEPSEEK_BASE_URL");
|
||||
std::env::remove_var("DEEPSEEK_MODEL");
|
||||
|
||||
let workspace_root = temp_workspace_root();
|
||||
let (ws_url, _frames, ws_handle) = start_browser_ws_server();
|
||||
let config_path = write_config(
|
||||
&workspace_root,
|
||||
"deepseek-test-key",
|
||||
"http://127.0.0.1:9",
|
||||
"deepseek-chat",
|
||||
Some(real_skill_lib_root().to_str().unwrap()),
|
||||
Some(&ws_url),
|
||||
Some("fault-details-report.collect_fault_details"),
|
||||
);
|
||||
|
||||
let transport = Arc::new(MockTransport::new(vec![]));
|
||||
let browser_tool = BrowserPipeTool::new(
|
||||
transport.clone(),
|
||||
test_policy(),
|
||||
vec![1, 2, 3, 4, 5, 6, 7, 8],
|
||||
)
|
||||
.with_response_timeout(Duration::from_secs(1));
|
||||
let runtime_context = AgentRuntimeContext::new(Some(config_path), workspace_root);
|
||||
|
||||
handle_browser_message_with_context(
|
||||
transport.as_ref(),
|
||||
&browser_tool,
|
||||
&runtime_context,
|
||||
BrowserMessage::SubmitTask {
|
||||
instruction: "打开知乎热榜,获取前10条数据,并导出 Excel".to_string(),
|
||||
conversation_id: String::new(),
|
||||
messages: vec![],
|
||||
page_url: String::new(),
|
||||
page_title: String::new(),
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
ws_handle.join().unwrap();
|
||||
|
||||
let sent = transport.sent_messages();
|
||||
let mode_logs = direct_submit_mode_logs(&sent);
|
||||
let completion = direct_submit_completion(&sent).expect("task completion");
|
||||
|
||||
assert!(
|
||||
mode_logs
|
||||
.iter()
|
||||
.any(|mode| mode == "zeroclaw_process_message_primary"),
|
||||
"expected orchestration mode log before direct submit: {sent:?}"
|
||||
);
|
||||
assert!(
|
||||
!mode_logs.iter().any(|mode| mode == "direct_skill_primary"),
|
||||
"unexpected direct submit mode log for zhihu ws submit: {sent:?}"
|
||||
);
|
||||
assert!(completion.0, "expected zhihu ws submit to succeed: {sent:?}");
|
||||
assert!(
|
||||
!completion
|
||||
.1
|
||||
.contains("direct submit skill requires page_url so expected_domain can be derived"),
|
||||
"unexpected direct-submit page_url failure: {sent:?}"
|
||||
);
|
||||
|
||||
std::env::remove_var("SGCLAW_DISABLE_POST_EXPORT_OPEN");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn production_submit_task_routes_zhihu_through_ws_backend_without_helper_bootstrap() {
|
||||
let _guard = env_lock().lock().unwrap_or_else(|err| err.into_inner());
|
||||
@@ -744,6 +818,7 @@ fn production_submit_task_routes_zhihu_through_ws_backend_without_helper_bootstr
|
||||
"deepseek-chat",
|
||||
Some(real_skill_lib_root().to_str().unwrap()),
|
||||
Some(&ws_url),
|
||||
None,
|
||||
);
|
||||
|
||||
let transport = Arc::new(MockTransport::new(vec![]));
|
||||
|
||||
Reference in New Issue
Block a user