forked from kent/consciousness
defs.rs: convert run_agent query to use RPC
Uses memory_rpc("memory_query", ...) instead of direct search::run_query.
Removes now-unused crate::search import.
Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
b863f77998
commit
a08f521b02
1 changed files with 14 additions and 13 deletions
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
use crate::graph::Graph;
|
||||
use crate::neuro::{consolidation_priority, ReplayItem};
|
||||
use crate::search;
|
||||
use crate::store::Store;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
|
@ -620,19 +619,21 @@ pub fn run_agent(
|
|||
) -> Result<super::prompts::AgentBatch, String> {
|
||||
let graph = store.build_graph();
|
||||
|
||||
// Run the query if present
|
||||
// Run the query if present, via RPC
|
||||
let keys = if !def.query.is_empty() {
|
||||
let mut stages = crate::query_parser::parse_stages(&def.query)?;
|
||||
let has_limit = stages.iter().any(|s|
|
||||
matches!(s, search::Stage::Transform(search::Transform::Limit(_))));
|
||||
if !has_limit {
|
||||
// Request extra results to compensate for exclusion filtering
|
||||
let padded = count + exclude.len().min(100);
|
||||
stages.push(search::Stage::Transform(search::Transform::Limit(padded)));
|
||||
}
|
||||
let results = search::run_query(&stages, vec![], &graph, store, false, count + exclude.len().min(100));
|
||||
let filtered: Vec<String> = results.into_iter()
|
||||
.map(|(k, _)| k)
|
||||
let padded = count + exclude.len().min(100);
|
||||
let query = if def.query.contains("limit:") {
|
||||
def.query.clone()
|
||||
} else {
|
||||
format!("{} | limit:{}", def.query, padded)
|
||||
};
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_query",
|
||||
serde_json::json!({"query": query}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let filtered: Vec<String> = result.lines()
|
||||
.filter(|l| !l.is_empty() && *l != "no results")
|
||||
.map(|s| s.to_string())
|
||||
.filter(|k| !exclude.contains(k))
|
||||
.take(count)
|
||||
.collect();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue