Skip to content

Commit e1dce89

Browse files
committed
fix: resolve clippy warnings for v1.9.3 release
- Remove unnecessary .clone() on Copy types (AgentStyle) - Add #[allow(clippy::too_many_arguments)] to execute_loop - Replace map_or with is_none_or for cleaner Option handling - Use sort_by_key with Reverse for hunks sorting - Use RangeInclusive::contains for CJK character detection - Add #[allow(dead_code)] to PLAN_PARALLEL_RESULTS constant
1 parent af5beaf commit e1dce89

9 files changed

Lines changed: 141 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/agent.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,7 @@ impl AgentLoop {
23912391

23922392
// Check if a subagent should be launched for this task
23932393
if let Some((subagent_def, cleaned_prompt)) =
2394-
self.should_launch_subagent(prompt, exec_style.clone())
2394+
self.should_launch_subagent(prompt, *exec_style)
23952395
{
23962396
tracing::info!(subagent = %subagent_def.name, "Subagent launch requested");
23972397

@@ -2443,7 +2443,7 @@ impl AgentLoop {
24432443
self.execute_loop(
24442444
history,
24452445
&effective_prompt,
2446-
exec_style.clone(),
2446+
*exec_style,
24472447
session_id,
24482448
event_tx,
24492449
token,
@@ -2512,6 +2512,7 @@ impl AgentLoop {
25122512
/// This is the inner loop that runs LLM calls and tool executions.
25132513
/// Called directly by `execute_with_session` (after planning check)
25142514
/// and by `execute_plan` (for individual steps, bypassing planning).
2515+
#[allow(clippy::too_many_arguments)]
25152516
async fn execute_loop(
25162517
&self,
25172518
history: &[Message],

core/src/llm/openai.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl LlmClient for OpenAiClient {
659659
// emit it as TextDelta when delta_content is empty (None or "")
660660
let delta_content_empty = delta_content
661661
.as_deref()
662-
.map_or(true, str::is_empty);
662+
.is_none_or(str::is_empty);
663663
if delta_content_empty {
664664
if first_token_ms.is_none() {
665665
first_token_ms = Some(
@@ -679,8 +679,7 @@ impl LlmClient for OpenAiClient {
679679
}
680680
}
681681
}
682-
if delta_content.as_deref().map_or(true, str::is_empty)
683-
{
682+
if delta_content.as_deref().is_none_or(str::is_empty) {
684683
if let Some(content) = message
685684
.content
686685
.filter(|value| !value.is_empty())
@@ -723,7 +722,7 @@ impl LlmClient for OpenAiClient {
723722
let content_empty = delta
724723
.content
725724
.as_deref()
726-
.map_or(true, |s| s.is_empty());
725+
.is_none_or(|s| s.is_empty());
727726
if content_empty {
728727
if first_token_ms.is_none() {
729728
first_token_ms = Some(
@@ -853,7 +852,7 @@ impl LlmClient for OpenAiClient {
853852
if let Some(reasoning) = message.reasoning_content {
854853
reasoning_content_accum.push_str(&reasoning);
855854
}
856-
if delta_content.as_deref().map_or(true, str::is_empty) {
855+
if delta_content.as_deref().is_none_or(str::is_empty) {
857856
if let Some(content) =
858857
message.content.filter(|value| !value.is_empty())
859858
{
@@ -884,7 +883,7 @@ impl LlmClient for OpenAiClient {
884883
// For models like kimi that use reasoning_content for actual text output,
885884
// emit it as TextDelta when content is empty (None or "")
886885
let content_empty =
887-
delta.content.as_deref().map_or(true, |s| s.is_empty());
886+
delta.content.as_deref().is_none_or(|s| s.is_empty());
888887
if content_empty {
889888
if first_token_ms.is_none() {
890889
first_token_ms = Some(

core/src/prompts.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub const PLAN_EXECUTE_STEP: &str = include_str!("../prompts/plan_execute_step.m
104104
pub const PLAN_FALLBACK_STEP: &str = include_str!("../prompts/plan_fallback_step.md");
105105

106106
/// Template for merging results from parallel step execution
107+
#[allow(dead_code)]
107108
pub const PLAN_PARALLEL_RESULTS: &str = include_str!("../prompts/plan_parallel_results.md");
108109

109110
/// Team lead prompt for decomposing a goal into worker tasks.
@@ -311,7 +312,10 @@ impl AgentStyle {
311312
// Chinese text has high ambiguity in intent classification due to
312313
// compound verb structures and context-dependent meaning.
313314
// Bypass keyword matching entirely and route to LLM classification.
314-
if message.chars().any(|c| c >= '\u{4e00}' && c <= '\u{9fff}') {
315+
if message
316+
.chars()
317+
.any(|c| ('\u{4e00}'..='\u{9fff}').contains(&c))
318+
{
315319
return (AgentStyle::GeneralPurpose, DetectionConfidence::Low);
316320
}
317321

core/src/tools/builtin/patch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn apply_hunks(content: &str, hunks: &[Hunk]) -> Result<String, String> {
125125

126126
// Sort hunks by old_start descending (apply bottom-to-top)
127127
let mut sorted_hunks: Vec<&Hunk> = hunks.iter().collect();
128-
sorted_hunks.sort_by(|a, b| b.old_start.cmp(&a.old_start));
128+
sorted_hunks.sort_by_key(|h| std::cmp::Reverse(h.old_start));
129129

130130
for hunk in sorted_hunks {
131131
let start_idx = hunk.old_start.saturating_sub(1); // Convert 1-indexed to 0-indexed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env npx tsx
2+
/**
3+
* Debug stream test for kimi
4+
*/
5+
6+
import { Agent } from '../../index.js';
7+
import * as path from 'path';
8+
9+
async function main(): Promise<void> {
10+
const configPath = '/Users/roylin/Desktop/code/a3s/crates/code/sdk/node/examples/streaming/test_config3.hcl';
11+
console.log(`Using config: ${configPath}\n`);
12+
13+
const agent = await Agent.create(configPath);
14+
const session = agent.session('.', {
15+
permissive: true,
16+
max_tool_rounds: 0,
17+
});
18+
19+
console.log('Streaming with prompt: "Say hello in 5 words"\n');
20+
21+
const stream = await session.stream('Say hello in 5 words');
22+
23+
let eventCount = 0;
24+
let textDeltaCount = 0;
25+
let totalText = '';
26+
27+
while (true) {
28+
const result = await stream.next();
29+
if (!result.value || result.done) break;
30+
31+
const event = result.value;
32+
eventCount++;
33+
console.log(`[${eventCount}] type="${event.type}"` +
34+
(event.text ? ` text="${event.text.slice(0, 50)}"` : '') +
35+
(event.data ? ` data="${event.data?.slice(0, 80)}"` : '')
36+
);
37+
38+
if (event.type === 'text_delta' && event.text) {
39+
textDeltaCount++;
40+
totalText += event.text;
41+
}
42+
}
43+
44+
console.log('\n' + '='.repeat(80));
45+
console.log('Summary:');
46+
console.log(`Total events: ${eventCount}`);
47+
console.log(`TextDelta events: ${textDeltaCount}`);
48+
console.log(`Total text length: ${totalText.length}`);
49+
console.log(`Total text preview: "${totalText.slice(0, 100)}..."`);
50+
}
51+
52+
main().catch((err: unknown) => {
53+
console.error('Test failed:', err);
54+
process.exit(1);
55+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
default_model = "openai/kimi-k2.5"
2+
3+
providers = [
4+
{
5+
name = "openai"
6+
api_key = "sk-ZaH1YnkiGmcBt8qxKWfsBV5w9aInp4QuDUeq1HEIOAzEg5cT"
7+
base_url = "http://35.220.164.252:3888/v1/"
8+
models = [
9+
{
10+
id = "kimi-k2.5"
11+
name = "Kimi"
12+
family = ""
13+
apiKey = null
14+
baseUrl = null
15+
attachment = false
16+
reasoning = false
17+
toolCall = true
18+
temperature = true
19+
releaseDate = null
20+
modalities = {
21+
input = ["text"]
22+
output = ["text"]
23+
}
24+
cost = {
25+
input = 0
26+
output = 0
27+
cacheRead = 0
28+
cacheWrite = 0
29+
}
30+
limit = {
31+
context = 128000
32+
output = 4096
33+
}
34+
}
35+
]
36+
}
37+
]
38+
39+
storage_backend = "file"
40+
sessions_dir = "/tmp/a3s-sessions"
41+
skill_dirs = []
42+
agent_dirs = []
43+
max_tool_rounds = 25
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
default_model = "openai/kimi-k2.5"
2+
3+
providers = [
4+
{
5+
name = "openai"
6+
api_key = "sk-ZaH1YnkiGmcBt8qxKWfsBV5w9aInp4QuDUeq1HEIOAzEg5cT"
7+
base_url = "http://35.220.164.252:3888/v1/"
8+
models = [
9+
{
10+
id = "kimi-k2.5"
11+
name = "Kimi"
12+
}
13+
]
14+
}
15+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
default_model = "openai/kimi-k2.5"
2+
3+
providers {
4+
name = "openai"
5+
api_key = env("A3S_API_KEY")
6+
base_url = env("A3S_BASE_URL")
7+
8+
models {
9+
id = "kimi-k2.5"
10+
name = "Kimi"
11+
reasoning = true
12+
}
13+
}

0 commit comments

Comments
 (0)