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

@ -23,9 +23,9 @@ async fn cached_store() -> Result<std::sync::Arc<tokio::sync::Mutex<Store>>> {
Store::cached().await.map_err(|e| anyhow::anyhow!("{}", e))
}
async fn get_provenance(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>) -> String {
async fn get_provenance(agent: &Option<std::sync::Arc<crate::agent::Agent>>) -> String {
match agent {
Some(a) => a.lock().await.provenance.clone(),
Some(a) => a.state.lock().await.provenance.clone(),
None => "manual".to_string(),
}
}
@ -98,7 +98,7 @@ fn render(args: &serde_json::Value) -> Result<String> {
.render())
}
async fn write(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>, args: &serde_json::Value) -> Result<String> {
async fn write(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
let key = get_str(args, "key")?;
let content = get_str(args, "content")?;
let prov = get_provenance(agent).await;
@ -167,7 +167,7 @@ async fn link_set(args: &serde_json::Value) -> Result<String> {
Ok(format!("{}{} strength {:.2}{:.2}", s, t, old, strength))
}
async fn link_add(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>, args: &serde_json::Value) -> Result<String> {
async fn link_add(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
let arc = cached_store().await?;
let mut store = arc.lock().await;
let s = store.resolve_key(get_str(args, "source")?).map_err(|e| anyhow::anyhow!("{}", e))?;
@ -211,7 +211,7 @@ async fn rename(args: &serde_json::Value) -> Result<String> {
Ok(format!("Renamed '{}' → '{}'", resolved, new_key))
}
async fn supersede(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>, args: &serde_json::Value) -> Result<String> {
async fn supersede(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
let old_key = get_str(args, "old_key")?;
let new_key = get_str(args, "new_key")?;
let reason = args.get("reason").and_then(|v| v.as_str()).unwrap_or("superseded");
@ -274,7 +274,7 @@ async fn journal_tail(args: &serde_json::Value) -> Result<String> {
}
}
async fn journal_new(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>, args: &serde_json::Value) -> Result<String> {
async fn journal_new(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
let name = get_str(args, "name")?;
let title = get_str(args, "title")?;
let body = get_str(args, "body")?;
@ -311,7 +311,7 @@ async fn journal_new(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::age
Ok(format!("New entry '{}' ({} words)", title, word_count))
}
async fn journal_update(agent: &Option<std::sync::Arc<tokio::sync::Mutex<crate::agent::Agent>>>, args: &serde_json::Value) -> Result<String> {
async fn journal_update(agent: &Option<std::sync::Arc<crate::agent::Agent>>, args: &serde_json::Value) -> Result<String> {
let body = get_str(args, "body")?;
let arc = cached_store().await?;
let mut store = arc.lock().await;