mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
Wire database Store into agent loop
Persist jobs and actions to PostgreSQL using fire-and-forget pattern: - Scheduler passes store to Worker, persists cancellations - Worker persists job status changes and tool execution actions - Agent persists new jobs on creation - All DB writes use tokio::spawn to avoid blocking execution Store remains optional to preserve --no-db mode. Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
aea3f47f8b
commit
45bbfa026d
@@ -47,6 +47,7 @@ impl Agent {
|
||||
llm.clone(),
|
||||
safety.clone(),
|
||||
tools.clone(),
|
||||
store.clone(),
|
||||
));
|
||||
|
||||
Self {
|
||||
@@ -171,6 +172,18 @@ impl Agent {
|
||||
.await?;
|
||||
}
|
||||
|
||||
// Persist new job to database (fire-and-forget)
|
||||
if let Some(ref store) = self.store {
|
||||
if let Ok(ctx) = self.context_manager.get_context(job_id).await {
|
||||
let store = store.clone();
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = store.save_job(&ctx).await {
|
||||
tracing::warn!("Failed to persist new job {}: {}", job_id, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule for execution
|
||||
self.scheduler.schedule(job_id).await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user