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:
parent
e73135a8d0
commit
1d61b091b0
9 changed files with 30 additions and 30 deletions
|
|
@ -63,11 +63,11 @@ pub struct AutoAgent {
|
|||
}
|
||||
|
||||
/// Per-run conversation backend — wraps a forked agent.
|
||||
struct Backend(std::sync::Arc<tokio::sync::Mutex<Agent>>);
|
||||
struct Backend(std::sync::Arc<Agent>);
|
||||
|
||||
impl Backend {
|
||||
async fn push_node(&mut self, node: AstNode) {
|
||||
self.0.lock().await.push_node(node);
|
||||
self.0.push_node(node).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ impl AutoAgent {
|
|||
/// Arc to read entries live during the run.
|
||||
pub async fn run_forked_shared(
|
||||
&mut self,
|
||||
agent: &std::sync::Arc<tokio::sync::Mutex<Agent>>,
|
||||
agent: &std::sync::Arc<Agent>,
|
||||
memory_keys: &[String],
|
||||
state: &std::collections::BTreeMap<String, String>,
|
||||
) -> Result<String, String> {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub(super) fn tools() -> [super::Tool; 3] {
|
|||
.ok_or_else(|| anyhow::anyhow!("'model' parameter is required"))?;
|
||||
if model.is_empty() { anyhow::bail!("'model' parameter cannot be empty"); }
|
||||
if let Some(agent) = agent {
|
||||
let mut a = agent.lock().await;
|
||||
let mut a = agent.state.lock().await;
|
||||
a.pending_model_switch = Some(model.to_string());
|
||||
}
|
||||
Ok(format!("Switching to model '{}' after this turn.", model))
|
||||
|
|
@ -24,7 +24,7 @@ pub(super) fn tools() -> [super::Tool; 3] {
|
|||
parameters_json: r#"{"type":"object","properties":{}}"#,
|
||||
handler: |agent, _v| Box::pin(async move {
|
||||
if let Some(agent) = agent {
|
||||
let mut a = agent.lock().await;
|
||||
let mut a = agent.state.lock().await;
|
||||
a.pending_yield = true;
|
||||
a.pending_dmn_pause = true;
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ pub(super) fn tools() -> [super::Tool; 3] {
|
|||
handler: |agent, v| Box::pin(async move {
|
||||
let msg = v.get("message").and_then(|v| v.as_str()).unwrap_or("Waiting for input.");
|
||||
if let Some(agent) = agent {
|
||||
let mut a = agent.lock().await;
|
||||
let mut a = agent.state.lock().await;
|
||||
a.pending_yield = true;
|
||||
}
|
||||
Ok(format!("Yielding. {}", msg))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue