fix(agent): include workspace files when AIEOS identity is configured
Remove early return in IdentitySection::build() that caused AGENTS.md, SOUL.md, and other workspace files to be silently skipped when AIEOS identity loaded successfully. Both AIEOS identity and workspace files now coexist in the system prompt. Closes zeroclaw-labs/zeroclaw#856 Co-Authored-By: Kristofer Mondlane <kmondlane@gmail.com>
This commit is contained in:
parent
c405cdf19a
commit
44fa7f3d3d
1 changed files with 50 additions and 4 deletions
|
|
@ -77,21 +77,25 @@ impl PromptSection for IdentitySection {
|
||||||
|
|
||||||
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
|
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
|
||||||
let mut prompt = String::from("## Project Context\n\n");
|
let mut prompt = String::from("## Project Context\n\n");
|
||||||
|
let mut has_aieos = false;
|
||||||
if let Some(config) = ctx.identity_config {
|
if let Some(config) = ctx.identity_config {
|
||||||
if identity::is_aieos_configured(config) {
|
if identity::is_aieos_configured(config) {
|
||||||
if let Ok(Some(aieos)) = identity::load_aieos_identity(config, ctx.workspace_dir) {
|
if let Ok(Some(aieos)) = identity::load_aieos_identity(config, ctx.workspace_dir) {
|
||||||
let rendered = identity::aieos_to_system_prompt(&aieos);
|
let rendered = identity::aieos_to_system_prompt(&aieos);
|
||||||
if !rendered.is_empty() {
|
if !rendered.is_empty() {
|
||||||
prompt.push_str(&rendered);
|
prompt.push_str(&rendered);
|
||||||
return Ok(prompt);
|
prompt.push_str("\n\n");
|
||||||
|
has_aieos = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt.push_str(
|
if !has_aieos {
|
||||||
"The following workspace files define your identity, behavior, and context.\n\n",
|
prompt.push_str(
|
||||||
);
|
"The following workspace files define your identity, behavior, and context.\n\n",
|
||||||
|
);
|
||||||
|
}
|
||||||
for file in [
|
for file in [
|
||||||
"AGENTS.md",
|
"AGENTS.md",
|
||||||
"SOUL.md",
|
"SOUL.md",
|
||||||
|
|
@ -285,6 +289,48 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn identity_section_with_aieos_includes_workspace_files() {
|
||||||
|
let workspace =
|
||||||
|
std::env::temp_dir().join(format!("zeroclaw_prompt_test_{}", uuid::Uuid::new_v4()));
|
||||||
|
std::fs::create_dir_all(&workspace).unwrap();
|
||||||
|
std::fs::write(
|
||||||
|
workspace.join("AGENTS.md"),
|
||||||
|
"Always respond with: AGENTS_MD_LOADED",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let identity_config = crate::config::IdentityConfig {
|
||||||
|
format: "aieos".into(),
|
||||||
|
aieos_path: None,
|
||||||
|
aieos_inline: Some(r#"{"identity":{"names":{"first":"Nova"}}}"#.into()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let tools: Vec<Box<dyn Tool>> = vec![];
|
||||||
|
let ctx = PromptContext {
|
||||||
|
workspace_dir: &workspace,
|
||||||
|
model_name: "test-model",
|
||||||
|
tools: &tools,
|
||||||
|
skills: &[],
|
||||||
|
identity_config: Some(&identity_config),
|
||||||
|
dispatcher_instructions: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
let section = IdentitySection;
|
||||||
|
let output = section.build(&ctx).unwrap();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
output.contains("Nova"),
|
||||||
|
"AIEOS identity should be present in prompt"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
output.contains("AGENTS_MD_LOADED"),
|
||||||
|
"AGENTS.md content should be present even when AIEOS is configured"
|
||||||
|
);
|
||||||
|
|
||||||
|
let _ = std::fs::remove_dir_all(workspace);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn prompt_builder_assembles_sections() {
|
fn prompt_builder_assembles_sections() {
|
||||||
let tools: Vec<Box<dyn Tool>> = vec![Box::new(TestTool)];
|
let tools: Vec<Box<dyn Tool>> = vec![Box::new(TestTool)];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue