Fix: compact() was clearing tool definitions from system section
compact() cleared and rebuilt the system section but only pushed the system prompt — tool definitions were lost. Since new() sets up the system section correctly (prompt + tools), compact() now only reloads identity and journal, leaving system untouched. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
d4d661df5b
commit
fc75b181cf
2 changed files with 9 additions and 3 deletions
|
|
@ -491,6 +491,13 @@ impl ResponseParser {
|
||||||
let handle = tokio::spawn(async move {
|
let handle = tokio::spawn(async move {
|
||||||
let mut parser = self;
|
let mut parser = self;
|
||||||
let agent_name = agent.state.lock().await.provenance.clone();
|
let agent_name = agent.state.lock().await.provenance.clone();
|
||||||
|
// One-shot debug: dump rendered prompt to file
|
||||||
|
{
|
||||||
|
let ctx = agent.context.lock().await;
|
||||||
|
let rendered = ctx.render();
|
||||||
|
let dump_path = format!("/tmp/poc-{}-prompt.txt", agent_name);
|
||||||
|
let _ = std::fs::write(&dump_path, &rendered);
|
||||||
|
}
|
||||||
let log_path = format!("/tmp/poc-{}.log", agent_name);
|
let log_path = format!("/tmp/poc-{}.log", agent_name);
|
||||||
let mut log_file = std::fs::OpenOptions::new()
|
let mut log_file = std::fs::OpenOptions::new()
|
||||||
.create(true).append(true).open(&log_path).ok();
|
.create(true).append(true).open(&log_path).ok();
|
||||||
|
|
|
||||||
|
|
@ -540,10 +540,9 @@ impl Agent {
|
||||||
|
|
||||||
pub async fn compact(&self) {
|
pub async fn compact(&self) {
|
||||||
match crate::config::reload_for_model(&self.app_config, &self.prompt_file) {
|
match crate::config::reload_for_model(&self.app_config, &self.prompt_file) {
|
||||||
Ok((system_prompt, personality)) => {
|
Ok((_system_prompt, personality)) => {
|
||||||
let mut ctx = self.context.lock().await;
|
let mut ctx = self.context.lock().await;
|
||||||
ctx.clear(Section::System);
|
// System section (prompt + tools) set by new(), don't touch it
|
||||||
ctx.push(Section::System, AstNode::system_msg(&system_prompt));
|
|
||||||
ctx.clear(Section::Identity);
|
ctx.clear(Section::Identity);
|
||||||
for (name, content) in &personality {
|
for (name, content) in &personality {
|
||||||
ctx.push(Section::Identity, AstNode::memory(name, content));
|
ctx.push(Section::Identity, AstNode::memory(name, content));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue