Wiring more

This commit is contained in:
Illia Polosukhin
2026-02-03 10:08:06 -08:00
parent 235f6aae18
commit 7210470544
18 changed files with 553 additions and 137 deletions
+5 -2
View File
@@ -368,9 +368,12 @@ impl Agent {
)
.await;
// Call LLM with thread context
// Call LLM with thread context and available tools
let reasoning = Reasoning::new(self.llm.clone(), self.safety.clone());
let context = ReasoningContext::new().with_messages(turn_messages);
let tool_defs = self.tools.tool_definitions().await;
let context = ReasoningContext::new()
.with_messages(turn_messages)
.with_tools(tool_defs);
let llm_result = reasoning.respond(&context).await;
// Re-acquire lock and check if interrupted
-16
View File
@@ -29,7 +29,6 @@ use std::time::Duration;
use tokio::sync::mpsc;
use crate::channels::OutgoingResponse;
use crate::error::WorkspaceError;
use crate::llm::{ChatMessage, CompletionRequest, LlmProvider};
use crate::workspace::Workspace;
@@ -277,21 +276,6 @@ pub fn spawn_heartbeat(
})
}
/// Update heartbeat state in the database.
pub async fn update_heartbeat_state(
workspace: &Workspace,
last_run: chrono::DateTime<chrono::Utc>,
) -> Result<(), WorkspaceError> {
// This would update the heartbeat_state table
// For now, we just log
tracing::debug!(
"Heartbeat state updated for user {} at {}",
workspace.user_id(),
last_run
);
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
+1 -4
View File
@@ -32,14 +32,12 @@ pub enum WorkerMessage {
/// Status of a scheduled job.
#[derive(Debug)]
pub struct ScheduledJob {
pub job_id: Uuid,
pub handle: JoinHandle<()>,
pub tx: mpsc::Sender<WorkerMessage>,
}
/// Status of a scheduled sub-task.
struct ScheduledSubtask {
task_id: Uuid,
handle: JoinHandle<Result<TaskOutput, Error>>,
}
@@ -137,7 +135,7 @@ impl Scheduler {
self.jobs
.write()
.await
.insert(job_id, ScheduledJob { job_id, handle, tx });
.insert(job_id, ScheduledJob { handle, tx });
tracing::info!("Scheduled job {} for execution", job_id);
Ok(())
@@ -203,7 +201,6 @@ impl Scheduler {
self.subtasks.write().await.insert(
task_id,
ScheduledSubtask {
task_id,
handle: tokio::spawn(async move {
// Wrap the handle to get its result
match handle.await {
+4
View File
@@ -66,10 +66,12 @@ pub trait SelfRepair: Send + Sync {
/// Default self-repair implementation.
pub struct DefaultSelfRepair {
context_manager: Arc<ContextManager>,
#[allow(dead_code)] // Will be used for time-based stuck detection
stuck_threshold: Duration,
max_repair_attempts: u32,
store: Option<Arc<Store>>,
builder: Option<Arc<dyn SoftwareBuilder>>,
#[allow(dead_code)] // Will be used for tool hot-reload after repair
tools: Option<Arc<ToolRegistry>>,
}
@@ -91,12 +93,14 @@ impl DefaultSelfRepair {
}
/// Add a Store for tool failure tracking.
#[allow(dead_code)] // Public API for configuring repair with persistence
pub fn with_store(mut self, store: Arc<Store>) -> Self {
self.store = Some(store);
self
}
/// Add a Builder and ToolRegistry for automatic tool repair.
#[allow(dead_code)] // Public API for enabling automatic tool repair
pub fn with_builder(
mut self,
builder: Arc<dyn SoftwareBuilder>,
+1 -8
View File
@@ -33,9 +33,7 @@ pub struct Worker {
/// Result of a tool execution with metadata for context building.
struct ToolExecResult {
tool_name: String,
result: Result<String, Error>,
duration: Duration,
}
impl Worker {
@@ -290,7 +288,6 @@ Report when the job is complete or if you encounter issues you cannot resolve."#
let store = self.store.clone();
async move {
let start = std::time::Instant::now();
let result = Self::execute_tool_inner(
tools,
context_manager,
@@ -300,11 +297,7 @@ Report when the job is complete or if you encounter issues you cannot resolve."#
&params,
)
.await;
ToolExecResult {
tool_name,
result,
duration: start.elapsed(),
}
ToolExecResult { result }
}
})
.collect();