Use Instructions as Prompt in Scheduler (#5359)

This commit is contained in:
Amed Rodriguez 2025-10-24 15:17:31 -07:00 committed by GitHub
parent 53391f2065
commit 0ca4e0ba4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -655,7 +655,9 @@ impl Scheduler {
schedule_sessions.push((session.id.clone(), session));
}
}
schedule_sessions.sort_by(|a, b| b.0.cmp(&a.0));
// Sort by created_at timestamp, newest first
schedule_sessions.sort_by(|a, b| b.1.created_at.cmp(&a.1.created_at));
let result_sessions: Vec<(String, Session)> =
schedule_sessions.into_iter().take(limit).collect();
@ -1171,14 +1173,10 @@ async fn run_scheduled_job_internal(
}
};
// Create session upfront for both cases
// Create session upfront
let session = match SessionManager::create_session(
current_dir.clone(),
if recipe.prompt.is_some() {
format!("Scheduled job: {}", job.id)
} else {
"Empty job - no prompt".to_string()
},
format!("Scheduled job: {}", job.id),
)
.await
{
@ -1199,7 +1197,13 @@ async fn run_scheduled_job_internal(
}
}
if let Some(ref prompt_text) = recipe.prompt {
// Use prompt if available, otherwise fall back to instructions
let prompt_text = recipe
.prompt
.as_ref()
.or(recipe.instructions.as_ref())
.unwrap();
let mut conversation =
Conversation::new_unvalidated(vec![Message::user().with_text(prompt_text.clone())]);
@ -1252,13 +1256,6 @@ async fn run_scheduled_job_internal(
});
}
}
} else {
tracing::warn!(
"[Job {}] Recipe '{}' has no prompt to execute.",
job.id,
job.source
);
}
if let Err(e) = SessionManager::update_session(&session.id)
.schedule_id(Some(job.id.clone()))