forked from kent/consciousness
memory: add agent-context placeholder, split context groups
Add `agent: bool` field to ContextGroup (default true) so agents get
personality/identity context without session-specific groups (journal,
where-am-i). Agents now get the full identity.md, reflections.md,
toolkit, etc. instead of the compact core-personality loader.
New {{agent-context}} placeholder resolves all agent-tagged groups
using the same get_group_content() as load-context.
This commit is contained in:
parent
c5ce6e515f
commit
b6bfb26369
4 changed files with 43 additions and 8 deletions
|
|
@ -412,6 +412,25 @@ fn resolve(
|
|||
Some(Resolved { text, keys: vec![] })
|
||||
}
|
||||
|
||||
// agent-context — personality/identity groups from load-context config
|
||||
"agent-context" => {
|
||||
let cfg = crate::config::get();
|
||||
let mut text = String::new();
|
||||
let mut keys = Vec::new();
|
||||
for group in &cfg.context_groups {
|
||||
if !group.agent { continue; }
|
||||
let entries = crate::cli::misc::get_group_content(group, store, &cfg);
|
||||
for (key, content) in entries {
|
||||
use std::fmt::Write;
|
||||
writeln!(text, "--- {} ({}) ---", key, group.label).ok();
|
||||
writeln!(text, "{}\n", content).ok();
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
if text.is_empty() { None }
|
||||
else { Some(Resolved { text, keys }) }
|
||||
}
|
||||
|
||||
// node:KEY — inline a node's content by key
|
||||
other if other.starts_with("node:") => {
|
||||
let key = &other[5..];
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ pub fn cmd_query(expr: &[String]) -> Result<(), String> {
|
|||
crate::query_parser::run_query(&store, &graph, &query_str)
|
||||
}
|
||||
|
||||
fn get_group_content(group: &crate::config::ContextGroup, store: &crate::store::Store, cfg: &crate::config::Config) -> Vec<(String, String)> {
|
||||
pub fn get_group_content(group: &crate::config::ContextGroup, store: &crate::store::Store, cfg: &crate::config::Config) -> Vec<(String, String)> {
|
||||
match group.source {
|
||||
crate::config::ContextSource::Journal => {
|
||||
let mut entries = Vec::new();
|
||||
|
|
|
|||
|
|
@ -33,8 +33,13 @@ pub struct ContextGroup {
|
|||
pub keys: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub source: ContextSource,
|
||||
/// Include this group in agent context (default true)
|
||||
#[serde(default = "default_true")]
|
||||
pub agent: bool,
|
||||
}
|
||||
|
||||
fn default_true() -> bool { true }
|
||||
|
||||
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
#[serde(default)]
|
||||
|
|
@ -92,11 +97,13 @@ impl Default for Config {
|
|||
label: "identity".into(),
|
||||
keys: vec!["identity".into()],
|
||||
source: ContextSource::Store,
|
||||
agent: true,
|
||||
},
|
||||
ContextGroup {
|
||||
label: "core-practices".into(),
|
||||
keys: vec!["core-practices".into()],
|
||||
source: ContextSource::Store,
|
||||
agent: true,
|
||||
},
|
||||
],
|
||||
llm_concurrency: 1,
|
||||
|
|
@ -243,7 +250,8 @@ impl Config {
|
|||
_ => ContextSource::Store,
|
||||
};
|
||||
|
||||
context_groups.push(ContextGroup { label: label.to_string(), keys, source });
|
||||
let agent = obj.get("agent").and_then(|v| v.as_bool()).unwrap_or(true);
|
||||
context_groups.push(ContextGroup { label: label.to_string(), keys, source, agent });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue