forked from kent/consciousness
agents: phase tracking, pid files, pipelining, unified cycle
- AgentStep with phase labels (=== PROMPT phase:name ===)
- PID files in state dir (pid-{PID} with JSON phase/timestamp)
- Built-in bail check: between steps, bail if other pid files exist
- surface_observe_cycle replaces surface_agent_cycle + journal_agent_cycle
- Reads surface output from state dir instead of parsing stdout
- Pipelining: starts new agent if running one is past surface phase
- link_set upserts (creates link if missing)
- Better error message for context window overflow
Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
11289667f5
commit
e20aeeeabe
8 changed files with 256 additions and 178 deletions
|
|
@ -12,9 +12,14 @@ use crate::neuro::{
|
|||
/// Result of building an agent prompt — includes both the prompt text
|
||||
/// and the keys of nodes selected for processing, so the caller can
|
||||
/// record visits after successful completion.
|
||||
/// A resolved step ready for execution.
|
||||
pub struct ResolvedStep {
|
||||
pub prompt: String,
|
||||
pub phase: String,
|
||||
}
|
||||
|
||||
pub struct AgentBatch {
|
||||
/// Prompt steps — single-step agents have one entry, multi-step have several.
|
||||
pub prompts: Vec<String>,
|
||||
pub steps: Vec<ResolvedStep>,
|
||||
pub node_keys: Vec<String>,
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +369,7 @@ pub fn split_plan_prompt(store: &Store, key: &str) -> Result<String, String> {
|
|||
let graph = store.build_graph();
|
||||
// Override the query — we have a specific key to split
|
||||
let keys = vec![key.to_string()];
|
||||
let template = def.prompts.first().ok_or_else(|| "split.agent has no prompts".to_string())?;
|
||||
let template = def.steps.first().map(|s| &s.prompt).ok_or_else(|| "split.agent has no steps".to_string())?;
|
||||
let (prompt, _) = super::defs::resolve_placeholders(template, store, &graph, &keys, 1);
|
||||
Ok(prompt)
|
||||
}
|
||||
|
|
@ -386,11 +391,11 @@ pub fn split_extract_prompt(store: &Store, parent_key: &str, child_key: &str, ch
|
|||
pub fn consolidation_batch(store: &Store, count: usize, auto: bool) -> Result<(), String> {
|
||||
if auto {
|
||||
let batch = agent_prompt(store, "replay", count)?;
|
||||
for (i, p) in batch.prompts.iter().enumerate() {
|
||||
if batch.prompts.len() > 1 {
|
||||
println!("=== STEP {} ===\n", i + 1);
|
||||
for (i, s) in batch.steps.iter().enumerate() {
|
||||
if batch.steps.len() > 1 {
|
||||
println!("=== STEP {} ({}) ===\n", i + 1, s.phase);
|
||||
}
|
||||
println!("{}", p);
|
||||
println!("{}", s.prompt);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue