Workerのリファクタリング

This commit is contained in:
2026-04-11 19:47:34 +09:00
parent 7249a8ee6a
commit 02b266dce7
5 changed files with 124 additions and 131 deletions
@@ -40,17 +40,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("📡 Sending request to LLM...");
// Mutable::run consumes self → (Locked, WorkerResult)
match worker.run("Tell me a very long story about a brave knight. Make it as detailed as possible with many paragraphs.").await {
Ok((_locked, WorkerResult::Finished)) => {
println!("✅ Task completed normally");
}
Ok((_locked, WorkerResult::Paused)) => {
println!("⏸️ Task paused");
}
Ok((_locked, WorkerResult::LimitReached)) => {
println!("🔒 Turn limit reached");
}
Ok(out) => match out.result {
WorkerResult::Finished => println!("✅ Task completed normally"),
WorkerResult::Paused => println!("⏸️ Task paused"),
WorkerResult::LimitReached => println!("🔒 Turn limit reached"),
},
Err(e) => {
println!("❌ Task error: {}", e);
}
+2 -2
View File
@@ -476,8 +476,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
return Ok(());
}
let (mut locked, _) = match worker.run(first_input).await {
Ok(pair) => pair,
let mut locked = match worker.run(first_input).await {
Ok(out) => out.worker,
Err(e) => {
eprintln!("\n❌ Error: {}", e);
return Ok(());