diff --git a/src/agent/tools/memory.rs b/src/agent/tools/memory.rs index f64a4d3..5fea14d 100644 --- a/src/agent/tools/memory.rs +++ b/src/agent/tools/memory.rs @@ -238,11 +238,26 @@ async fn supersede(agent: &Option>, args: &s async fn query(args: &serde_json::Value) -> Result { let query_str = get_str(args, "query")?; + let format = args.get("format").and_then(|v| v.as_str()).unwrap_or("compact"); let arc = cached_store().await?; let store = arc.lock().await; let graph = store.build_graph(); - crate::query_parser::query_to_string(&store, &graph, query_str) - .map_err(|e| anyhow::anyhow!("{}", e)) + + match format { + "full" => { + // Rich output with full content, graph metrics, hub analysis + let stages = crate::search::Stage::parse_pipeline(query_str) + .map_err(|e| anyhow::anyhow!("{}", e))?; + let results = crate::search::run_query(&stages, vec![], &graph, &store, false, 100); + let keys: Vec = results.into_iter().map(|(k, _)| k).collect(); + let items = crate::subconscious::defs::keys_to_replay_items(&store, &keys, &graph); + Ok(crate::subconscious::prompts::format_nodes_section(&store, &items, &graph)) + } + _ => { + crate::query_parser::query_to_string(&store, &graph, query_str) + .map_err(|e| anyhow::anyhow!("{}", e)) + } + } } // ── Journal tools ────────────────────────────────────────────── diff --git a/src/subconscious/agents/challenger.agent b/src/subconscious/agents/challenger.agent index 2257ada..3cf17f0 100644 --- a/src/subconscious/agents/challenger.agent +++ b/src/subconscious/agents/challenger.agent @@ -1,4 +1,4 @@ -{"agent": "challenger", "query": "all | type:semantic | not-visited:challenger,14d | sort:priority | limit:10", "schedule": "weekly"} +{"agent": "challenger", "schedule": "weekly"} # Challenger Agent — Adversarial Truth-Testing @@ -52,4 +52,4 @@ For each target node, one of: ## Target nodes to challenge -{{NODES}} +{{tool: memory_query {"query": "all | type:semantic | not-visited:challenger,14d | sort:priority | limit:10", "format": "full"}}} diff --git a/src/subconscious/agents/connector.agent b/src/subconscious/agents/connector.agent index 78a8009..8d9f6b1 100644 --- a/src/subconscious/agents/connector.agent +++ b/src/subconscious/agents/connector.agent @@ -1,4 +1,4 @@ -{"agent": "connector", "query": "all | type:semantic | not-visited:connector,7d | sort:priority | limit:20", "schedule": "daily"} +{"agent": "connector", "schedule": "daily"} # Connector Agent — Cross-Domain Insight @@ -83,4 +83,4 @@ you're exploring and you have context to judge them, reweight those too. ## Nodes to examine for cross-community connections -{{NODES}} +{{tool: memory_query {"query": "all | type:semantic | not-visited:connector,7d | sort:priority | limit:20", "format": "full"}}} diff --git a/src/subconscious/agents/extractor.agent b/src/subconscious/agents/extractor.agent index 07ff0ec..fd2195d 100644 --- a/src/subconscious/agents/extractor.agent +++ b/src/subconscious/agents/extractor.agent @@ -1,4 +1,4 @@ -{"agent": "extractor", "query": "all | not-visited:extractor,7d | sort:priority | limit:3 | spread | not-visited:extractor,7d | limit:20", "schedule": "daily"} +{"agent": "extractor", "schedule": "daily"} # Extractor Agent — Knowledge Organizer {{tool: memory_render core-personality}} @@ -48,4 +48,4 @@ pattern you've found. ## Neighborhood nodes -{{NODES}} +{{tool: memory_query {"query": "all | not-visited:extractor,7d | sort:priority | limit:3 | spread | not-visited:extractor,7d | limit:20", "format": "full"}}} diff --git a/src/subconscious/agents/linker.agent b/src/subconscious/agents/linker.agent index caba70e..8bc8a3f 100644 --- a/src/subconscious/agents/linker.agent +++ b/src/subconscious/agents/linker.agent @@ -1,4 +1,4 @@ -{"agent":"linker","query":"all | not-visited:linker,7d | sort:isolation*0.7+recency(linker)*0.3 | limit:5","schedule":"daily"} +{"agent":"linker","schedule":"daily"} # Linker Agent — Relational Binding @@ -8,7 +8,7 @@ ## Seed nodes -{{nodes}} +{{tool: memory_query {"query": "all | not-visited:linker,7d | sort:isolation*0.7+recency(linker)*0.3 | limit:5", "format": "full"}}} {{tool: memory_render memory-instructions-core-subconscious}} diff --git a/src/subconscious/agents/replay.agent b/src/subconscious/agents/replay.agent index 5620d65..fd67b15 100644 --- a/src/subconscious/agents/replay.agent +++ b/src/subconscious/agents/replay.agent @@ -1,4 +1,4 @@ -{"agent": "replay", "query": "all | !type:daily | !type:weekly | !type:monthly | sort:priority | limit:15", "schedule": "daily"} +{"agent": "replay", "schedule": "daily"} # Replay Agent — Hippocampal Replay + Schema Assimilation @@ -44,4 +44,4 @@ clusters and determine how it fits. ## Nodes to review -{{NODES}} +{{tool: memory_query {"query": "all | !type:daily | !type:weekly | !type:monthly | sort:priority | limit:15", "format": "full"}}} diff --git a/src/subconscious/agents/transfer.agent b/src/subconscious/agents/transfer.agent index c607649..2d86a1d 100644 --- a/src/subconscious/agents/transfer.agent +++ b/src/subconscious/agents/transfer.agent @@ -1,4 +1,4 @@ -{"agent": "transfer", "query": "all | type:episodic | sort:timestamp | limit:15", "schedule": "daily"} +{"agent": "transfer", "schedule": "daily"} # Transfer Agent — Complementary Learning Systems {{tool: memory_render core-personality}} @@ -51,4 +51,4 @@ entries, and extract those patterns into semantic nodes. ## Episodes to process -{{EPISODES}} +{{tool: memory_query {"query": "all | type:episodic | sort:timestamp | limit:15", "format": "full"}}} diff --git a/src/subconscious/defs.rs b/src/subconscious/defs.rs index 787d957..1fe8377 100644 --- a/src/subconscious/defs.rs +++ b/src/subconscious/defs.rs @@ -845,7 +845,7 @@ pub fn run_agent( } /// Convert a list of keys to ReplayItems with priority and graph metrics. -fn keys_to_replay_items( +pub fn keys_to_replay_items( store: &Store, keys: &[String], graph: &Graph, diff --git a/src/subconscious/prompts.rs b/src/subconscious/prompts.rs index db29b92..93862c5 100644 --- a/src/subconscious/prompts.rs +++ b/src/subconscious/prompts.rs @@ -66,7 +66,7 @@ pub fn format_topology_header(graph: &Graph) -> String { n, e, graph.community_count(), sigma, alpha, gini, avg_cc, hub_list) } -pub(super) fn format_nodes_section(store: &Store, items: &[ReplayItem], graph: &Graph) -> String { +pub fn format_nodes_section(store: &Store, items: &[ReplayItem], graph: &Graph) -> String { let hub_thresh = graph.hub_threshold(); let mut out = String::new(); for item in items {