thought: wire up agent and subconscious to use shared tools

- agent/tools/mod.rs: remove duplicated tool implementations, delegate
  to thought::dispatch for shared tools, keep only agent-specific
  tools (control, vision, working_stack)
- subconscious/api.rs: replace duplicated memory/tool dispatch with
  thought::dispatch, use thought::all_definitions() for tool schemas
- Delete agent/tools/{bash,read,write,edit,grep,glob_tool,journal,memory}.rs
  (now live in thought/)

Both poc-agent and subconscious agents now use the same tool
implementations through the thought layer. Agent-specific behavior
(node tracking in runner.rs, control tools) stays in agent/.
This commit is contained in:
ProofOfConcept 2026-03-27 15:27:33 -04:00
parent bfc558893a
commit 36bde60ba0
10 changed files with 31 additions and 1101 deletions

View file

@ -9,7 +9,7 @@
use crate::agent::api::ApiClient;
use crate::agent::types::*;
use crate::agent::tools::{self, ProcessTracker};
use crate::thought::{self, ProcessTracker};
use crate::agent::ui_channel::StreamTarget;
use std::sync::OnceLock;
@ -32,7 +32,7 @@ fn get_client() -> Result<&'static ApiClient, String> {
/// context carries forward naturally between steps.
/// Returns the final text response after all steps complete.
pub async fn call_api_with_tools(
agent: &str,
_agent: &str,
prompts: &[String],
temperature: Option<f32>,
bail_fn: Option<&(dyn Fn(usize) -> Result<(), String> + Sync)>,
@ -43,13 +43,8 @@ pub async fn call_api_with_tools(
// Set up a UI channel — we drain reasoning tokens into the log
let (ui_tx, mut ui_rx) = crate::agent::ui_channel::channel();
// Build tool definitions — memory and journal tools for graph operations
let all_defs = tools::definitions();
let tool_defs: Vec<ToolDef> = all_defs.into_iter()
.filter(|d| d.function.name.starts_with("memory_")
|| d.function.name.starts_with("journal_")
|| d.function.name == "output")
.collect();
// Build tool definitions — all shared tools (memory, files, bash, journal)
let tool_defs = thought::all_definitions();
let tracker = ProcessTracker::new();
// Start with the first prompt as a user message
@ -162,25 +157,9 @@ pub async fn call_api_with_tools(
}
};
let output = if call.function.name.starts_with("memory_")
|| call.function.name.starts_with("journal_")
|| call.function.name == "output" {
let prov = format!("agent:{}", agent);
match crate::agent::tools::memory::dispatch(
&call.function.name, &args, Some(&prov),
) {
Ok(text) => crate::agent::tools::ToolOutput {
text, is_yield: false, images: Vec::new(),
model_switch: None, dmn_pause: false,
},
Err(e) => crate::agent::tools::ToolOutput {
text: format!("Error: {}", e),
is_yield: false, images: Vec::new(),
model_switch: None, dmn_pause: false,
},
}
} else {
tools::dispatch(&call.function.name, &args, &tracker).await
let output = match thought::dispatch(&call.function.name, &args, &tracker).await {
Some(out) => out,
None => thought::ToolOutput::error(format!("Unknown tool: {}", call.function.name)),
};
log(&format!("TOOL RESULT ({} chars):\n{}", output.text.len(), output.text));