fix: improve task status

This commit is contained in:
pavel 2026-02-11 00:26:47 +01:00
commit 4dc3d84d38
2 changed files with 8 additions and 8 deletions

View file

@ -98,14 +98,14 @@ impl Scheduler {
let mut agent = Agent::new(zen_key, tavily_key, task.goal.clone())?;
tokio::spawn(async move {
let (logs, answer) = match agent.run().await {
Ok(res) => res,
Err(e) => (format!("Scheduled run failed: {}", e), None),
let (logs, answer, status) = match agent.run().await {
Ok((logs, answer)) => (logs, answer, "completed".to_string()),
Err(e) => (format!("Scheduled run failed: {}", e), None, "failed".to_string()),
};
let run_complete = task_run::ActiveModel {
id: Set(run_id),
status: Set("completed".to_string()),
status: Set(status),
logs: Set(logs),
answer: Set(answer),
..Default::default()

View file

@ -275,9 +275,9 @@ async fn execute_agent_run(
)
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
let (logs, answer) = match agent.run().await {
Ok((logs, answer)) => (logs, answer),
Err(e) => (format!("Execution failed: {}", e), None),
let (logs, answer, status) = match agent.run().await {
Ok((logs, answer)) => (logs, answer, "completed".to_string()),
Err(e) => (format!("Execution failed: {}", e), None, "failed".to_string()),
};
// Update with final logs and status
@ -293,7 +293,7 @@ async fn execute_agent_run(
run.logs = Set(logs.clone());
run.answer = Set(answer.clone());
run.status = Set("completed".to_string());
run.status = Set(status);
run.update(&state.db)
.await