WIP: Agent/AgentState — 36 errors remaining, all .lock() → .state.lock() or .context.lock()

Bulk replaced Arc<Mutex<Agent>> with Arc<Agent> across all files.
Fixed control.rs, memory.rs tool handlers. Fixed oneshot Backend.
Remaining errors are all agent.lock() → agent.state.lock() or
agent.context.lock() in mind/, user/, and a few in mod.rs.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 15:40:36 -04:00
parent e73135a8d0
commit 1d61b091b0
9 changed files with 30 additions and 30 deletions

View file

@ -295,7 +295,7 @@ pub struct SubconsciousSnapshot {
pub turn: usize,
pub last_run_secs_ago: Option<f64>,
/// Shared handle to the forked agent — UI locks to read entries.
pub forked_agent: Option<Arc<tokio::sync::Mutex<crate::agent::Agent>>>,
pub forked_agent: Option<Arc<crate::agent::Agent>>,
/// Entry index where the fork diverged.
pub fork_point: usize,
/// Shared persistent state — accumulated across all agent runs.
@ -311,7 +311,7 @@ struct SubconsciousAgent {
last_run: Option<Instant>,
/// The forked agent for the current/last run. Shared with the
/// spawned task so the UI can read entries live.
forked_agent: Option<Arc<tokio::sync::Mutex<crate::agent::Agent>>>,
forked_agent: Option<Arc<crate::agent::Agent>>,
/// Entry index where the fork diverged from the conscious agent.
fork_point: usize,
handle: Option<tokio::task::JoinHandle<(AutoAgent, Result<String, String>)>>,
@ -428,7 +428,7 @@ impl Subconscious {
/// Collect results from finished agents, inject outputs into the
/// conscious agent's context.
pub async fn collect_results(&mut self, agent: &Arc<tokio::sync::Mutex<Agent>>) {
pub async fn collect_results(&mut self, agent: &Arc<Agent>) {
let finished: Vec<(usize, tokio::task::JoinHandle<(AutoAgent, Result<String, String>)>)> =
self.agents.iter_mut().enumerate().filter_map(|(i, sub)| {
if sub.handle.as_ref().is_some_and(|h| h.is_finished()) {
@ -511,7 +511,7 @@ impl Subconscious {
}
/// Trigger subconscious agents that are due to run.
pub async fn trigger(&mut self, agent: &Arc<tokio::sync::Mutex<Agent>>) {
pub async fn trigger(&mut self, agent: &Arc<Agent>) {
let (conversation_bytes, memory_keys) = {
let ag = agent.lock().await;
let bytes = ag.context.conversation().iter()