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 tiktoken_rs::CoreBPE;
use std::io::Write; use std::io::Write;
use std::process::{Command, Stdio};
use crate::agent::api::ApiClient; use crate::agent::api::ApiClient;
use crate::agent::journal; use crate::agent::journal;
@ -129,8 +128,9 @@ impl Agent {
agent agent
} }
/// Run poc-hook for a given event, returning any output to inject. /// Run memory search for a given event, returning any output to inject.
fn run_hook(&self, event: &str, prompt: &str) -> Option<String> { /// 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() let transcript_path = self.conversation_log.as_ref()
.map(|l| l.path().to_string_lossy().to_string()) .map(|l| l.path().to_string_lossy().to_string())
.unwrap_or_default(); .unwrap_or_default();
@ -139,23 +139,9 @@ impl Agent {
"hook_event_name": event, "hook_event_name": event,
"session_id": self.session_id, "session_id": self.session_id,
"transcript_path": transcript_path, "transcript_path": transcript_path,
"prompt": prompt,
}); });
let mut child = Command::new("poc-hook") let text = crate::memory_search::run_hook(&hook_input.to_string());
.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();
if text.trim().is_empty() { if text.trim().is_empty() {
None None
} else { } else {