fix: restore zhihu export routing before direct submit
Keep Zhihu hotlist export requests on the orchestration path so natural-language submits without page context no longer fail in direct-submit routing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -258,31 +258,6 @@ pub fn handle_browser_message_with_context<T: Transport + 'static>(
|
|||||||
};
|
};
|
||||||
return transport.send(&completion);
|
return transport.send(&completion);
|
||||||
}
|
}
|
||||||
if settings
|
|
||||||
.direct_submit_skill
|
|
||||||
.as_deref()
|
|
||||||
.map(str::trim)
|
|
||||||
.is_some_and(|value| !value.is_empty())
|
|
||||||
{
|
|
||||||
let _ = send_mode_log(transport, "direct_skill_primary");
|
|
||||||
let completion = match crate::compat::direct_skill_runtime::execute_direct_submit_skill(
|
|
||||||
browser_tool.clone(),
|
|
||||||
&instruction,
|
|
||||||
&task_context,
|
|
||||||
&context.workspace_root,
|
|
||||||
&settings,
|
|
||||||
) {
|
|
||||||
Ok(outcome) => AgentMessage::TaskComplete {
|
|
||||||
success: outcome.success,
|
|
||||||
summary: outcome.summary,
|
|
||||||
},
|
|
||||||
Err(err) => AgentMessage::TaskComplete {
|
|
||||||
success: false,
|
|
||||||
summary: err.to_string(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return transport.send(&completion);
|
|
||||||
}
|
|
||||||
if crate::compat::orchestration::should_use_primary_orchestration(
|
if crate::compat::orchestration::should_use_primary_orchestration(
|
||||||
&instruction,
|
&instruction,
|
||||||
task_context.page_url.as_deref(),
|
task_context.page_url.as_deref(),
|
||||||
@@ -311,6 +286,31 @@ pub fn handle_browser_message_with_context<T: Transport + 'static>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if settings
|
||||||
|
.direct_submit_skill
|
||||||
|
.as_deref()
|
||||||
|
.map(str::trim)
|
||||||
|
.is_some_and(|value| !value.is_empty())
|
||||||
|
{
|
||||||
|
let _ = send_mode_log(transport, "direct_skill_primary");
|
||||||
|
let completion = match crate::compat::direct_skill_runtime::execute_direct_submit_skill(
|
||||||
|
browser_tool.clone(),
|
||||||
|
&instruction,
|
||||||
|
&task_context,
|
||||||
|
&context.workspace_root,
|
||||||
|
&settings,
|
||||||
|
) {
|
||||||
|
Ok(outcome) => AgentMessage::TaskComplete {
|
||||||
|
success: outcome.success,
|
||||||
|
summary: outcome.summary,
|
||||||
|
},
|
||||||
|
Err(err) => AgentMessage::TaskComplete {
|
||||||
|
success: false,
|
||||||
|
summary: err.to_string(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return transport.send(&completion);
|
||||||
|
}
|
||||||
let _ = send_mode_log(transport, "compat_llm_primary");
|
let _ = send_mode_log(transport, "compat_llm_primary");
|
||||||
match crate::compat::runtime::execute_task_with_sgclaw_settings(
|
match crate::compat::runtime::execute_task_with_sgclaw_settings(
|
||||||
transport,
|
transport,
|
||||||
|
|||||||
@@ -135,6 +135,16 @@ fn submit_fault_details_message() -> BrowserMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn submit_zhihu_hotlist_export_message() -> BrowserMessage {
|
||||||
|
BrowserMessage::SubmitTask {
|
||||||
|
instruction: "打开知乎热榜,获取前10条数据,并导出 Excel".to_string(),
|
||||||
|
conversation_id: String::new(),
|
||||||
|
messages: vec![],
|
||||||
|
page_url: String::new(),
|
||||||
|
page_title: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn direct_submit_mode_logs(sent: &[AgentMessage]) -> Vec<String> {
|
fn direct_submit_mode_logs(sent: &[AgentMessage]) -> Vec<String> {
|
||||||
sent.iter()
|
sent.iter()
|
||||||
.filter_map(|message| match message {
|
.filter_map(|message| match message {
|
||||||
@@ -530,6 +540,47 @@ fn submit_task_treats_error_report_artifact_as_failure() {
|
|||||||
assert!(completion.1.contains("detail_normalization_failed"));
|
assert!(completion.1.contains("detail_normalization_failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn submit_task_routes_zhihu_hotlist_export_before_direct_submit() {
|
||||||
|
std::env::remove_var("DEEPSEEK_API_KEY");
|
||||||
|
std::env::remove_var("DEEPSEEK_BASE_URL");
|
||||||
|
std::env::remove_var("DEEPSEEK_MODEL");
|
||||||
|
|
||||||
|
let skill_root = build_direct_runtime_skill_root();
|
||||||
|
let runtime_context = direct_submit_runtime_context(&skill_root);
|
||||||
|
let transport = Arc::new(MockTransport::new(vec![]));
|
||||||
|
let browser_tool = BrowserPipeTool::new(
|
||||||
|
transport.clone(),
|
||||||
|
policy_for_domains(&["www.zhihu.com"]),
|
||||||
|
vec![1, 2, 3, 4, 5, 6, 7, 8],
|
||||||
|
)
|
||||||
|
.with_response_timeout(Duration::from_secs(1));
|
||||||
|
|
||||||
|
handle_browser_message_with_context(
|
||||||
|
transport.as_ref(),
|
||||||
|
&browser_tool,
|
||||||
|
&runtime_context,
|
||||||
|
submit_zhihu_hotlist_export_message(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let sent = transport.sent_messages();
|
||||||
|
let mode_logs = direct_submit_mode_logs(&sent);
|
||||||
|
let completion = direct_submit_completion(&sent).expect("task completion");
|
||||||
|
|
||||||
|
assert_eq!(mode_logs, vec!["zeroclaw_process_message_primary".to_string()]);
|
||||||
|
assert!(
|
||||||
|
!completion.0,
|
||||||
|
"expected zhihu export without page context to fail before browser actions: {sent:?}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
!completion
|
||||||
|
.1
|
||||||
|
.contains("direct submit skill requires page_url so expected_domain can be derived"),
|
||||||
|
"unexpected direct submit fallback: {sent:?}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn direct_skill_mode_logs_direct_skill_primary() {
|
fn direct_skill_mode_logs_direct_skill_primary() {
|
||||||
std::env::remove_var("DEEPSEEK_API_KEY");
|
std::env::remove_var("DEEPSEEK_API_KEY");
|
||||||
|
|||||||
Reference in New Issue
Block a user