Skip to content

Commit 47fbe34

Browse files
committed
fix: clean hosted web search clippy
1 parent d816ad2 commit 47fbe34

3 files changed

Lines changed: 39 additions & 27 deletions

File tree

crates/core/src/query.rs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,29 @@ fn emit_hosted_tool_start<F>(
472472
}
473473
}
474474

475+
struct HostedToolResultEvent<'a> {
476+
id: &'a str,
477+
name: &'a str,
478+
input: &'a serde_json::Value,
479+
output: Option<serde_json::Value>,
480+
status: Option<String>,
481+
}
482+
475483
fn emit_hosted_tool_result<F>(
476484
emit: &F,
477485
emitted_tool_results: &mut HashSet<String>,
478486
session_cwd: &std::path::Path,
479-
id: &str,
480-
name: &str,
481-
input: &serde_json::Value,
482-
output: Option<serde_json::Value>,
483-
status: Option<String>,
487+
event: HostedToolResultEvent<'_>,
484488
) where
485489
F: Fn(QueryEvent),
486490
{
491+
let HostedToolResultEvent {
492+
id,
493+
name,
494+
input,
495+
output,
496+
status,
497+
} = event;
487498
if !emitted_tool_results.insert(id.to_string()) {
488499
return;
489500
}
@@ -901,11 +912,13 @@ pub async fn query(
901912
&emit,
902913
&mut emitted_hosted_tool_results,
903914
&session.cwd,
904-
&id,
905-
&name,
906-
&input,
907-
output,
908-
status,
915+
HostedToolResultEvent {
916+
id: &id,
917+
name: &name,
918+
input: &input,
919+
output,
920+
status,
921+
},
909922
);
910923
}
911924
Ok(StreamEvent::ToolCallInputDelta {
@@ -1059,11 +1072,13 @@ pub async fn query(
10591072
&emit,
10601073
&mut emitted_hosted_tool_results,
10611074
&session.cwd,
1062-
&id,
1063-
&name,
1064-
&input,
1065-
output.clone(),
1066-
status.clone(),
1075+
HostedToolResultEvent {
1076+
id: &id,
1077+
name: &name,
1078+
input: &input,
1079+
output: output.clone(),
1080+
status: status.clone(),
1081+
},
10671082
);
10681083
}
10691084
}
@@ -1095,11 +1110,13 @@ pub async fn query(
10951110
&emit,
10961111
&mut emitted_hosted_tool_results,
10971112
&session.cwd,
1098-
&id,
1099-
&name,
1100-
&input,
1101-
None,
1102-
Some("completed".to_string()),
1113+
HostedToolResultEvent {
1114+
id: &id,
1115+
name: &name,
1116+
input: &input,
1117+
output: None,
1118+
status: Some("completed".to_string()),
1119+
},
11031120
);
11041121
}
11051122

crates/provider/src/hosted_tools.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ pub(crate) fn apply_openai_chat_completions_hosted_tools(
2121
root: &mut Value,
2222
hosted_tools: &[HostedToolDefinition],
2323
) {
24-
if let Some(options) = hosted_tools.iter().find_map(|tool| match tool {
25-
HostedToolDefinition::WebSearch(options) => Some(options),
26-
}) {
24+
if let Some(HostedToolDefinition::WebSearch(options)) = hosted_tools.iter().next() {
2725
let mut value = Map::new();
2826
if let Some(search_context_size) = &options.search_context_size {
2927
value.insert(

crates/tui/src/worker.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,10 +3099,7 @@ fn summarize_tool_call(payload: &ToolCallPayload) -> String {
30993099
if is_web_search_tool_name(&payload.tool_name)
31003100
&& let Some(query) = web_search_query(&payload.parameters)
31013101
{
3102-
return format!(
3103-
"Web Search({})",
3104-
serde_json::Value::String(query).to_string()
3105-
);
3102+
return format!("Web Search({})", serde_json::Value::String(query));
31063103
}
31073104

31083105
let detail = summarize_tool_input(&payload.tool_name, &payload.parameters);

0 commit comments

Comments
 (0)