fix: improve task status
This commit is contained in:
parent
886d408c3b
commit
4dc3d84d38
2 changed files with 8 additions and 8 deletions
|
|
@ -98,14 +98,14 @@ impl Scheduler {
|
||||||
let mut agent = Agent::new(zen_key, tavily_key, task.goal.clone())?;
|
let mut agent = Agent::new(zen_key, tavily_key, task.goal.clone())?;
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let (logs, answer) = match agent.run().await {
|
let (logs, answer, status) = match agent.run().await {
|
||||||
Ok(res) => res,
|
Ok((logs, answer)) => (logs, answer, "completed".to_string()),
|
||||||
Err(e) => (format!("Scheduled run failed: {}", e), None),
|
Err(e) => (format!("Scheduled run failed: {}", e), None, "failed".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let run_complete = task_run::ActiveModel {
|
let run_complete = task_run::ActiveModel {
|
||||||
id: Set(run_id),
|
id: Set(run_id),
|
||||||
status: Set("completed".to_string()),
|
status: Set(status),
|
||||||
logs: Set(logs),
|
logs: Set(logs),
|
||||||
answer: Set(answer),
|
answer: Set(answer),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
||||||
|
|
@ -275,9 +275,9 @@ async fn execute_agent_run(
|
||||||
)
|
)
|
||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||||
|
|
||||||
let (logs, answer) = match agent.run().await {
|
let (logs, answer, status) = match agent.run().await {
|
||||||
Ok((logs, answer)) => (logs, answer),
|
Ok((logs, answer)) => (logs, answer, "completed".to_string()),
|
||||||
Err(e) => (format!("Execution failed: {}", e), None),
|
Err(e) => (format!("Execution failed: {}", e), None, "failed".to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update with final logs and status
|
// Update with final logs and status
|
||||||
|
|
@ -293,7 +293,7 @@ async fn execute_agent_run(
|
||||||
|
|
||||||
run.logs = Set(logs.clone());
|
run.logs = Set(logs.clone());
|
||||||
run.answer = Set(answer.clone());
|
run.answer = Set(answer.clone());
|
||||||
run.status = Set("completed".to_string());
|
run.status = Set(status);
|
||||||
|
|
||||||
run.update(&state.db)
|
run.update(&state.db)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue