Skip to content

Commit 32079e6

Browse files
committed
fix(agents): resolve clippy collapsible-if and expect-used lints
Collapse nested if blocks into let-chains (collapsible_if) in runner.rs and tool_parsing.rs. Allow expect_used in tool_grammar test module where panicking on None is the desired test behavior.
1 parent 9748f7c commit 32079e6

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

crates/agents/src/runner.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -756,19 +756,19 @@ pub async fn run_agent_loop_with_context(
756756

757757
// Fallback: parse tool calls from model text if the provider returned
758758
// no structured tool calls (some providers/models emit text-based calls).
759-
if response.tool_calls.is_empty() {
760-
if let Some(ref text) = response.text {
761-
let (parsed, remaining) = parse_tool_calls_from_text(text);
762-
if !parsed.is_empty() {
763-
info!(
764-
native_tools,
765-
count = parsed.len(),
766-
first_tool = %parsed[0].name,
767-
"parsed tool call(s) from text fallback"
768-
);
769-
response.text = remaining;
770-
response.tool_calls = parsed;
771-
}
759+
if response.tool_calls.is_empty()
760+
&& let Some(ref text) = response.text
761+
{
762+
let (parsed, remaining) = parse_tool_calls_from_text(text);
763+
if !parsed.is_empty() {
764+
info!(
765+
native_tools,
766+
count = parsed.len(),
767+
first_tool = %parsed[0].name,
768+
"parsed tool call(s) from text fallback"
769+
);
770+
response.text = remaining;
771+
response.tool_calls = parsed;
772772
}
773773
}
774774

crates/agents/src/tool_parsing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ pub fn parse_tool_calls_from_text(text: &str) -> (Vec<ToolCall>, Option<String>)
5959
blocks.sort_by_key(|b| b.start);
6060
let mut merged: Vec<ParsedBlock> = Vec::with_capacity(blocks.len());
6161
for block in blocks {
62-
if let Some(last) = merged.last() {
63-
if block.start < last.end {
64-
continue; // overlapping — skip
65-
}
62+
if let Some(last) = merged.last()
63+
&& block.start < last.end
64+
{
65+
continue; // overlapping — skip
6666
}
6767
merged.push(block);
6868
}

crates/providers/src/local_gguf/tool_grammar.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ ws ::= [ \t\n]*
7373
}
7474

7575
#[cfg(test)]
76+
#[allow(clippy::expect_used)]
7677
mod tests {
7778
use super::*;
7879

0 commit comments

Comments
 (0)