Skip to content

Commit d595894

Browse files
ZhiXiao-Linclaude
andcommitted
style: cargo fmt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1ca93fc commit d595894

7 files changed

Lines changed: 98 additions & 62 deletions

File tree

core/examples/sdk_chat.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ async fn main() -> anyhow::Result<()> {
118118
}
119119
}
120120
ContentBlock::ToolUse { name, .. } => Some(format!("[tool_use: {}]", name)),
121-
ContentBlock::ToolResult { content, .. } => {
122-
Some(format!("[tool_result: {}]", &content[..content.len().min(40)]))
123-
}
121+
ContentBlock::ToolResult { content, .. } => Some(format!(
122+
"[tool_result: {}]",
123+
&content[..content.len().min(40)]
124+
)),
124125
})
125126
.collect::<Vec<_>>()
126127
.join(" | ");
@@ -160,7 +161,10 @@ async fn main() -> anyhow::Result<()> {
160161
},
161162
];
162163
let custom_prompt = "What is the secret number? Reply with just the number.";
163-
println!(" Custom history: {} messages injected", custom_history.len());
164+
println!(
165+
" Custom history: {} messages injected",
166+
custom_history.len()
167+
);
164168
println!(" Prompt: {}", custom_prompt);
165169
let result3 = session.send(custom_prompt, Some(&custom_history)).await?;
166170
println!(" Response: {}", result3.text.trim());

core/examples/sdk_skills.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ fn main() {
7676
);
7777

7878
// Content: built-in agents
79-
assert!(delegate.content.contains("explore"), "should reference explore");
80-
assert!(delegate.content.contains("general"), "should reference general");
79+
assert!(
80+
delegate.content.contains("explore"),
81+
"should reference explore"
82+
);
83+
assert!(
84+
delegate.content.contains("general"),
85+
"should reference general"
86+
);
8187
assert!(delegate.content.contains("plan"), "should reference plan");
8288
println!(" [ok] content references agents: explore, general, plan");
8389

core/src/agent.rs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,8 +1639,7 @@ impl AgentLoop {
16391639

16401640
for tool_call in query_tools {
16411641
// Pre-execution checks: malformed args
1642-
if let Some(parse_error) =
1643-
tool_call.args.get("__parse_error").and_then(|v| v.as_str())
1642+
if let Some(parse_error) = tool_call.args.get("__parse_error").and_then(|v| v.as_str())
16441643
{
16451644
let error_msg = format!("Error: {}", parse_error);
16461645
if let Some(tx) = event_tx {
@@ -1981,7 +1980,12 @@ impl AgentLoop {
19811980
if ready.len() == 1 {
19821981
// === Single step: sequential execution (preserves history chain) ===
19831982
let step_id = &ready[0];
1984-
let step = plan.steps.iter().find(|s| s.id == *step_id).unwrap().clone();
1983+
let step = plan
1984+
.steps
1985+
.iter()
1986+
.find(|s| s.id == *step_id)
1987+
.unwrap()
1988+
.clone();
19851989
let step_number = plan.steps.iter().position(|s| s.id == *step_id).unwrap() + 1;
19861990

19871991
// Send step start event
@@ -4861,7 +4865,11 @@ mod extra_agent_tests {
48614865
];
48624866

48634867
let (query, sequential) = partition_by_lane(&tool_calls);
4864-
assert_eq!(query.len(), 6, "all read-only tools should be in query lane");
4868+
assert_eq!(
4869+
query.len(),
4870+
6,
4871+
"all read-only tools should be in query lane"
4872+
);
48654873
assert_eq!(sequential.len(), 0);
48664874
}
48674875

@@ -5003,21 +5011,12 @@ mod extra_agent_tests {
50035011
let config = AgentConfig::default();
50045012

50055013
let (event_tx, _) = broadcast::channel(100);
5006-
let queue = SessionLaneQueue::new(
5007-
"test-session",
5008-
SessionQueueConfig::default(),
5009-
event_tx,
5010-
)
5011-
.await
5012-
.unwrap();
5014+
let queue = SessionLaneQueue::new("test-session", SessionQueueConfig::default(), event_tx)
5015+
.await
5016+
.unwrap();
50135017

5014-
let agent = AgentLoop::new(
5015-
mock_client,
5016-
tool_executor,
5017-
test_tool_context(),
5018-
config,
5019-
)
5020-
.with_queue(Arc::new(queue));
5018+
let agent = AgentLoop::new(mock_client, tool_executor, test_tool_context(), config)
5019+
.with_queue(Arc::new(queue));
50215020

50225021
assert!(agent.command_queue.is_some());
50235022
}
@@ -5078,7 +5077,9 @@ mod extra_agent_tests {
50785077
while let Some(event) = rx.recv().await {
50795078
match event {
50805079
AgentEvent::StepStart { step_id, .. } => step_starts.push(step_id),
5081-
AgentEvent::StepEnd { step_id, status, .. } => {
5080+
AgentEvent::StepEnd {
5081+
step_id, status, ..
5082+
} => {
50825083
assert_eq!(status, TaskStatus::Completed);
50835084
step_ends.push(step_id);
50845085
}
@@ -5190,13 +5191,9 @@ mod extra_agent_tests {
51905191

51915192
let mut plan = ExecutionPlan::new("Test failure", Complexity::Medium);
51925193
plan.add_step(Task::new("s1", "Independent step"));
5193-
plan.add_step(
5194-
Task::new("s2", "Depends on s1").with_dependencies(vec!["s1".to_string()]),
5195-
);
5194+
plan.add_step(Task::new("s2", "Depends on s1").with_dependencies(vec!["s1".to_string()]));
51965195
plan.add_step(Task::new("s3", "Another independent"));
5197-
plan.add_step(
5198-
Task::new("s4", "Depends on s2").with_dependencies(vec!["s2".to_string()]),
5199-
);
5196+
plan.add_step(Task::new("s4", "Depends on s2").with_dependencies(vec!["s2".to_string()]));
52005197

52015198
let (tx, mut rx) = mpsc::channel(100);
52025199
let _result = agent.execute_plan(&[], &plan, Some(tx)).await.unwrap();
@@ -5227,10 +5224,7 @@ mod extra_agent_tests {
52275224
completed_steps.contains(&"s3".to_string()),
52285225
"s3 should complete"
52295226
);
5230-
assert!(
5231-
failed_steps.contains(&"s2".to_string()),
5232-
"s2 should fail"
5233-
);
5227+
assert!(failed_steps.contains(&"s2".to_string()), "s2 should fail");
52345228
// s4 should NOT appear in either list — it was never started
52355229
assert!(
52365230
!completed_steps.contains(&"s4".to_string()),

core/src/agent_api.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,7 @@ impl AgentSession {
326326
/// When `history` is `None`, uses (and auto-updates) the session's
327327
/// internal conversation history. When `Some`, uses the provided
328328
/// history instead (the internal history is **not** modified).
329-
pub async fn send(
330-
&self,
331-
prompt: &str,
332-
history: Option<&[Message]>,
333-
) -> Result<AgentResult> {
329+
pub async fn send(&self, prompt: &str, history: Option<&[Message]>) -> Result<AgentResult> {
334330
let agent_loop = self.build_agent_loop();
335331

336332
let use_internal = history.is_none();
@@ -370,7 +366,9 @@ impl AgentSession {
370366
let prompt = prompt.to_string();
371367

372368
let handle = tokio::spawn(async move {
373-
let _ = agent_loop.execute(&effective_history, &prompt, Some(tx)).await;
369+
let _ = agent_loop
370+
.execute(&effective_history, &prompt, Some(tx))
371+
.await;
374372
});
375373

376374
Ok((rx, handle))
@@ -446,11 +444,7 @@ impl AgentSession {
446444
/// Complete an external task by ID.
447445
///
448446
/// Returns `true` if the task was found and completed, `false` if not found.
449-
pub async fn complete_external_task(
450-
&self,
451-
task_id: &str,
452-
result: ExternalTaskResult,
453-
) -> bool {
447+
pub async fn complete_external_task(&self, task_id: &str, result: ExternalTaskResult) -> bool {
454448
if let Some(ref queue) = self.command_queue {
455449
queue.complete_external_task(task_id, result).await
456450
} else {
@@ -809,7 +803,9 @@ mod tests {
809803
let agent = Agent::from_config(test_config()).await.unwrap();
810804
let qc = SessionQueueConfig::default();
811805
let opts = SessionOptions::new().with_queue_config(qc);
812-
let session = agent.session("/tmp/test-workspace-qstats", Some(opts)).unwrap();
806+
let session = agent
807+
.session("/tmp/test-workspace-qstats", Some(opts))
808+
.unwrap();
813809
let stats = session.queue_stats().await;
814810
// Fresh queue with no commands should have zero stats
815811
assert_eq!(stats.total_pending, 0);
@@ -821,7 +817,9 @@ mod tests {
821817
let agent = Agent::from_config(test_config()).await.unwrap();
822818
let qc = SessionQueueConfig::default();
823819
let opts = SessionOptions::new().with_queue_config(qc);
824-
let session = agent.session("/tmp/test-workspace-ext", Some(opts)).unwrap();
820+
let session = agent
821+
.session("/tmp/test-workspace-ext", Some(opts))
822+
.unwrap();
825823
let tasks = session.pending_external_tasks().await;
826824
assert!(tasks.is_empty());
827825
}
@@ -831,7 +829,9 @@ mod tests {
831829
let agent = Agent::from_config(test_config()).await.unwrap();
832830
let qc = SessionQueueConfig::default().with_dlq(Some(100));
833831
let opts = SessionOptions::new().with_queue_config(qc);
834-
let session = agent.session("/tmp/test-workspace-dlq", Some(opts)).unwrap();
832+
let session = agent
833+
.session("/tmp/test-workspace-dlq", Some(opts))
834+
.unwrap();
835835
let dead = session.dead_letters().await;
836836
assert!(dead.is_empty());
837837
}
@@ -842,7 +842,9 @@ mod tests {
842842
// Metrics not enabled
843843
let qc = SessionQueueConfig::default();
844844
let opts = SessionOptions::new().with_queue_config(qc);
845-
let session = agent.session("/tmp/test-workspace-nomet", Some(opts)).unwrap();
845+
let session = agent
846+
.session("/tmp/test-workspace-nomet", Some(opts))
847+
.unwrap();
846848
let metrics = session.queue_metrics().await;
847849
assert!(metrics.is_none());
848850
}
@@ -852,7 +854,9 @@ mod tests {
852854
let agent = Agent::from_config(test_config()).await.unwrap();
853855
let qc = SessionQueueConfig::default().with_metrics();
854856
let opts = SessionOptions::new().with_queue_config(qc);
855-
let session = agent.session("/tmp/test-workspace-met", Some(opts)).unwrap();
857+
let session = agent
858+
.session("/tmp/test-workspace-met", Some(opts))
859+
.unwrap();
856860
let metrics = session.queue_metrics().await;
857861
assert!(metrics.is_some());
858862
}
@@ -862,7 +866,9 @@ mod tests {
862866
let agent = Agent::from_config(test_config()).await.unwrap();
863867
let qc = SessionQueueConfig::default();
864868
let opts = SessionOptions::new().with_queue_config(qc);
865-
let session = agent.session("/tmp/test-workspace-handler", Some(opts)).unwrap();
869+
let session = agent
870+
.session("/tmp/test-workspace-handler", Some(opts))
871+
.unwrap();
866872

867873
// Set Execute lane to External mode
868874
session

core/src/planning/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,7 @@ mod tests {
635635
plan.add_step(Task::new("s1", "Step 1"));
636636
plan.add_step(Task::new("s2", "Step 2"));
637637
plan.add_step(
638-
Task::new("s3", "Step 3")
639-
.with_dependencies(vec!["s1".to_string(), "s2".to_string()]),
638+
Task::new("s3", "Step 3").with_dependencies(vec!["s1".to_string(), "s2".to_string()]),
640639
);
641640

642641
// Wave 1: s1 and s2

core/src/tools/skill.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,7 @@ allowed-tools: InvalidFormat, AlsoInvalid
753753
fn test_builtin_skills_includes_delegate_task() {
754754
let skills = builtin_skills();
755755
let delegate = skills.iter().find(|s| s.name == "delegate-task");
756-
assert!(
757-
delegate.is_some(),
758-
"delegate-task skill should be present"
759-
);
756+
assert!(delegate.is_some(), "delegate-task skill should be present");
760757

761758
let d = delegate.unwrap();
762759
assert_eq!(d.kind, SkillKind::Instruction);
@@ -770,10 +767,7 @@ allowed-tools: InvalidFormat, AlsoInvalid
770767
#[test]
771768
fn test_builtin_delegate_task_content() {
772769
let skills = builtin_skills();
773-
let skill = skills
774-
.iter()
775-
.find(|s| s.name == "delegate-task")
776-
.unwrap();
770+
let skill = skills.iter().find(|s| s.name == "delegate-task").unwrap();
777771

778772
// Verify key content sections exist
779773
assert!(

sdk/node/package-lock.json

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)