ActiveTools wrapper: replace SharedActiveTools Arc<Mutex<Vec>>
New ActiveTools struct with proper methods: push, remove, abort_all, take_finished, take_foreground, iter, len. Lives directly on AgentState, no separate Arc<Mutex> needed. TUI reads active tools through agent.state.try_lock(). Turn loop uses helpers instead of manual index iteration. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
9c9618d034
commit
31a41fa042
5 changed files with 23 additions and 26 deletions
|
|
@ -264,8 +264,6 @@ impl Mind {
|
|||
config: SessionConfig,
|
||||
turn_tx: mpsc::Sender<(Result<TurnResult>, StreamTarget)>,
|
||||
) -> Self {
|
||||
let shared_active_tools = crate::agent::tools::shared_active_tools();
|
||||
|
||||
let client = ApiClient::new(&config.api_base, &config.api_key, &config.model);
|
||||
let conversation_log = log::ConversationLog::new(
|
||||
config.session_dir.join("conversation.jsonl"),
|
||||
|
|
@ -278,7 +276,7 @@ impl Mind {
|
|||
config.app.clone(),
|
||||
config.prompt_file.clone(),
|
||||
conversation_log,
|
||||
shared_active_tools,
|
||||
crate::agent::tools::ActiveTools::new(),
|
||||
).await;
|
||||
|
||||
let shared = Arc::new(std::sync::Mutex::new(MindState::new(config.app.dmn.max_turns)));
|
||||
|
|
@ -352,10 +350,7 @@ impl Mind {
|
|||
}
|
||||
MindCommand::Interrupt => {
|
||||
self.shared.lock().unwrap().interrupt();
|
||||
let active_tools = self.agent.state.lock().await.active_tools.clone();
|
||||
let mut tools = active_tools.lock().unwrap();
|
||||
for entry in tools.drain(..) { entry.handle.abort(); }
|
||||
drop(tools);
|
||||
self.agent.state.lock().await.active_tools.abort_all();
|
||||
if let Some(h) = self.shared.lock().unwrap().turn_handle.take() { h.abort(); }
|
||||
self.shared.lock().unwrap().turn_active = false;
|
||||
let _ = self.turn_watch.send(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue