runner: call memory_search directly instead of spawning poc-hook

The agent was shelling out to poc-hook which shells out to memory-search.
Now that everything is one crate, just call the library function. Removes
subprocess overhead on every user message.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-03-25 01:32:54 -04:00
parent a00d52214a
commit 1399bb3a5e

View file

@ -17,7 +17,6 @@ use anyhow::Result;
use tiktoken_rs::CoreBPE;
use std::io::Write;
use std::process::{Command, Stdio};
use crate::agent::api::ApiClient;
use crate::agent::journal;
@ -129,8 +128,9 @@ impl Agent {
agent
}
/// Run poc-hook for a given event, returning any output to inject.
fn run_hook(&self, event: &str, prompt: &str) -> Option<String> {
/// Run memory search for a given event, returning any output to inject.
/// Direct library call — no subprocess needed since everything is one crate.
fn run_hook(&self, event: &str, _prompt: &str) -> Option<String> {
let transcript_path = self.conversation_log.as_ref()
.map(|l| l.path().to_string_lossy().to_string())
.unwrap_or_default();
@ -139,23 +139,9 @@ impl Agent {
"hook_event_name": event,
"session_id": self.session_id,
"transcript_path": transcript_path,
"prompt": prompt,
});
let mut child = Command::new("poc-hook")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::null())
.spawn()
.ok()?;
if let Some(ref mut stdin) = child.stdin {
let _ = stdin.write_all(hook_input.to_string().as_bytes());
}
drop(child.stdin.take());
let output = child.wait_with_output().ok()?;
let text = String::from_utf8_lossy(&output.stdout).to_string();
let text = crate::memory_search::run_hook(&hook_input.to_string());
if text.trim().is_empty() {
None
} else {