Replace push() with explicit push_log() and push_no_log()

No implicit auto-logging. Call sites choose:
- push_log: new conversation entries (user messages, tool results,
  surfaced memories, assistant responses)
- push_no_log: system prompt, identity, journal, restore from log,
  compact reload, tests

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-09 01:10:40 -04:00
parent 6529aba069
commit c53c4f9071
3 changed files with 21 additions and 22 deletions

View file

@ -172,7 +172,7 @@ impl Agent {
) -> Arc<Self> {
let mut context = ContextState::new();
context.conversation_log = conversation_log;
context.push(Section::System, AstNode::system_msg(&system_prompt));
context.push_no_log(Section::System, AstNode::system_msg(&system_prompt));
let tool_defs: Vec<String> = tools::tools().iter()
.map(|t| t.to_json()).collect();
@ -186,11 +186,11 @@ impl Agent {
IMPORTANT: Function calls MUST follow the specified format.",
tool_defs.join("\n"),
);
context.push(Section::System, AstNode::system_msg(&tools_text));
context.push_no_log(Section::System, AstNode::system_msg(&tools_text));
}
for (name, content) in &personality {
context.push(Section::Identity, AstNode::memory(name, content));
context.push_no_log(Section::Identity, AstNode::memory(name, content));
}
let session_id = format!("consciousness-{}", chrono::Utc::now().format("%Y%m%d-%H%M%S"));
@ -267,7 +267,7 @@ impl Agent {
pub async fn push_node(&self, node: AstNode) {
let node = node.with_timestamp(chrono::Utc::now());
self.context.lock().await.push(Section::Conversation, node);
self.context.lock().await.push_log(Section::Conversation, node);
self.state.lock().await.changed.notify_one();
}
@ -315,7 +315,7 @@ impl Agent {
let branch_idx = {
let mut ctx = agent.context.lock().await;
let idx = ctx.len(Section::Conversation);
ctx.push(Section::Conversation,
ctx.push_log(Section::Conversation,
AstNode::branch(Role::Assistant, vec![])
.with_timestamp(chrono::Utc::now()));
idx
@ -471,7 +471,7 @@ impl Agent {
{
let mut ctx = agent.context.lock().await;
for node in nodes {
ctx.push(Section::Conversation, node);
ctx.push_log(Section::Conversation, node);
}
}
agent.state.lock().await.changed.notify_one();
@ -529,7 +529,7 @@ impl Agent {
let mut ctx = self.context.lock().await;
ctx.clear(Section::Journal);
for entry in entries {
ctx.push(Section::Journal, entry);
ctx.push_no_log(Section::Journal, entry);
}
}
@ -540,7 +540,7 @@ impl Agent {
// System section (prompt + tools) set by new(), don't touch it
ctx.clear(Section::Identity);
for (name, content) in &personality {
ctx.push(Section::Identity, AstNode::memory(name, content));
ctx.push_no_log(Section::Identity, AstNode::memory(name, content));
}
}
Err(e) => {