mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-30 16:19:21 +00:00
Integrate Codex patterns: task scheduler, TUI, sessions, compaction
Add Codex-inspired patterns for improved agent architecture: **Task Scheduler (Phase 1 & 4)** - New Task enum with Job, ToolExec, Background variants - TaskHandler trait for custom background tasks - Scheduler.spawn_subtask() and spawn_batch() for parallel execution - Worker executes multiple tools in parallel via futures::join_all **Tool Approval System (Phase 6)** - Tool.requires_approval() method (default false for sandboxed tools) - HttpTool marked as requiring approval (external network) - MCP protocol annotations: destructive_hint, side_effects_hint **Ratatui TUI CLI (Phase 2)** - Replace blocking stdin with event-driven TUI - ChatComposer with history navigation and tab completion - ApprovalOverlay modal with y/n/a keyboard shortcuts - Raw mode with proper terminal cleanup **Session/Turn Model (Phase 3)** - Session, Thread, Turn structs for conversation tracking - Submission enum for user input, approvals, undo, interrupt - UndoManager with checkpoint-based undo/redo **Context Compaction (Phase 5)** - ContextMonitor with token estimation and threshold checks - CompactionStrategy: Summarize, Truncate, MoveToWorkspace - ContextCompactor writes summaries to workspace daily logs Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
d047c23b2d
commit
09032d69cb
+26
-10
@@ -140,8 +140,20 @@ impl Reasoning {
|
||||
&self,
|
||||
context: &ReasoningContext,
|
||||
) -> Result<Option<ToolSelection>, LlmError> {
|
||||
let tools = self.select_tools(context).await?;
|
||||
Ok(tools.into_iter().next())
|
||||
}
|
||||
|
||||
/// Select tools to execute (may return multiple for parallel execution).
|
||||
///
|
||||
/// The LLM may return multiple tool calls if it determines they can be
|
||||
/// executed in parallel. This enables more efficient job completion.
|
||||
pub async fn select_tools(
|
||||
&self,
|
||||
context: &ReasoningContext,
|
||||
) -> Result<Vec<ToolSelection>, LlmError> {
|
||||
if context.available_tools.is_empty() {
|
||||
return Ok(None);
|
||||
return Ok(vec![]);
|
||||
}
|
||||
|
||||
let request =
|
||||
@@ -151,16 +163,20 @@ impl Reasoning {
|
||||
|
||||
let response = self.llm.complete_with_tools(request).await?;
|
||||
|
||||
if let Some(tool_call) = response.tool_calls.first() {
|
||||
Ok(Some(ToolSelection {
|
||||
tool_name: tool_call.name.clone(),
|
||||
parameters: tool_call.arguments.clone(),
|
||||
reasoning: response.content.unwrap_or_default(),
|
||||
let reasoning = response.content.unwrap_or_default();
|
||||
|
||||
let selections: Vec<ToolSelection> = response
|
||||
.tool_calls
|
||||
.into_iter()
|
||||
.map(|tool_call| ToolSelection {
|
||||
tool_name: tool_call.name,
|
||||
parameters: tool_call.arguments,
|
||||
reasoning: reasoning.clone(),
|
||||
alternatives: vec![],
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(selections)
|
||||
}
|
||||
|
||||
/// Evaluate whether a task was completed successfully.
|
||||
|
||||
Reference in New Issue
Block a user