Max Turnの実装
This commit is contained in:
@@ -49,6 +49,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
match result {
|
||||
PodRunResult::Finished => println!("(finished)"),
|
||||
PodRunResult::Paused => println!("(paused)"),
|
||||
PodRunResult::LimitReached => println!("(turn limit reached)"),
|
||||
}
|
||||
|
||||
// 5. Extract the assistant's reply from history
|
||||
|
||||
@@ -11,7 +11,7 @@ use llm_worker_persistence::Store;
|
||||
use tokio::sync::{broadcast, mpsc};
|
||||
|
||||
use crate::pod::{Pod, PodRunResult, PodError};
|
||||
use protocol::{ErrorCode, Event, Method, TurnResult};
|
||||
use protocol::{ErrorCode, Event, Method, RunResult, TurnResult};
|
||||
use crate::runtime_dir::RuntimeDir;
|
||||
use crate::shared_state::{PodSharedState, PodStatus};
|
||||
use crate::socket_server::SocketServer;
|
||||
@@ -193,10 +193,15 @@ where
|
||||
tokio::select! {
|
||||
result = &mut pod_future => {
|
||||
return match result {
|
||||
Ok(r) => match r {
|
||||
PodRunResult::Finished => PodStatus::Idle,
|
||||
PodRunResult::Paused => PodStatus::Paused,
|
||||
},
|
||||
Ok(r) => {
|
||||
let (status, run_result) = match r {
|
||||
PodRunResult::Finished => (PodStatus::Idle, RunResult::Finished),
|
||||
PodRunResult::Paused => (PodStatus::Paused, RunResult::Paused),
|
||||
PodRunResult::LimitReached => (PodStatus::Idle, RunResult::LimitReached),
|
||||
};
|
||||
let _ = event_tx.send(Event::RunEnd { result: run_result });
|
||||
status
|
||||
}
|
||||
Err(e) => {
|
||||
let code = worker_error_code(&e);
|
||||
let _ = event_tx.send(Event::Error {
|
||||
|
||||
@@ -142,6 +142,7 @@ pub fn apply_worker_manifest<C: LlmClient>(worker: &mut Worker<C>, wm: &WorkerMa
|
||||
config.temperature = Some(temperature);
|
||||
}
|
||||
worker.set_request_config(config);
|
||||
worker.set_max_turns(wm.max_turns.map(|n| n.get()));
|
||||
}
|
||||
|
||||
/// Result of a Pod run.
|
||||
@@ -151,6 +152,8 @@ pub enum PodRunResult {
|
||||
Finished,
|
||||
/// The LLM paused (e.g. awaiting user confirmation via a hook).
|
||||
Paused,
|
||||
/// The worker reached its configured max_turns limit.
|
||||
LimitReached,
|
||||
}
|
||||
|
||||
impl From<llm_worker::WorkerResult> for PodRunResult {
|
||||
@@ -158,6 +161,7 @@ impl From<llm_worker::WorkerResult> for PodRunResult {
|
||||
match r {
|
||||
llm_worker::WorkerResult::Finished => PodRunResult::Finished,
|
||||
llm_worker::WorkerResult::Paused => PodRunResult::Paused,
|
||||
llm_worker::WorkerResult::LimitReached => PodRunResult::LimitReached,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user