Skip to content

Personal AI, On Personal Devices

Python

feat: expand system_prompt_template with instruction on agent creation

Jon Saad-Falconccea853e5ead
diff --git a/src/openjarvis/agents/manager.py b/src/openjarvis/agents/manager.py
index ba11f1ff..e191b46c 100644
--- a/src/openjarvis/agents/manager.py
+++ b/src/openjarvis/agents/manager.py
@@ -488,6 +488,15 @@ class AgentManager:
if overrides:
config.update(overrides)
agent_type = config.pop("agent_type", "monitor_operative")
+
+ # Expand system_prompt_template with instruction
+ prompt_tpl = config.pop("system_prompt_template", "")
+ if prompt_tpl:
+ instruction = config.get("instruction", "")
+ config["system_prompt"] = prompt_tpl.format(
+ instruction=instruction or "(No specific instruction provided)",
+ )
+
return self.create_agent(name=name, agent_type=agent_type, config=config)
# ── Message queue ─────────────────────────────────────────────
diff --git a/tests/agents/test_template_prompts.py b/tests/agents/test_template_prompts.py
new file mode 100644
index 00000000..c8ff2d2b
--- /dev/null
+++ b/tests/agents/test_template_prompts.py
@@ -0,0 +1,40 @@
+"""Tests for system_prompt_template expansion in agent creation."""
+
+from __future__ import annotations
+
+from openjarvis.agents.manager import AgentManager
+
+
+def test_create_from_template_expands_system_prompt(tmp_path):
+ """system_prompt_template should be expanded with the instruction."""
+ mgr = AgentManager(db_path=str(tmp_path / "test.db"))
+ agent = mgr.create_from_template(
+ "research_monitor",
+ "Test Agent",
+ overrides={"instruction": "Monitor AI safety papers"},
+ )
+ config = agent["config"]
+ # system_prompt should contain the expanded instruction
+ assert "Monitor AI safety papers" in config.get("system_prompt", "")
+ # system_prompt_template should NOT be in the stored config
+ assert "system_prompt_template" not in config
+ mgr.close()
+
+
+def test_create_from_template_without_instruction(tmp_path):
+ """Template with no instruction should still have a system_prompt."""
+ mgr = AgentManager(db_path=str(tmp_path / "test.db"))
+ agent = mgr.create_from_template("research_monitor", "Test Agent")
+ config = agent["config"]
+ assert "system_prompt" in config
+ assert len(config["system_prompt"]) > 100 # non-trivial prompt
+ mgr.close()
+
+
+def test_create_from_template_preserves_icon(tmp_path):
+ """Template icon field should be preserved in config."""
+ mgr = AgentManager(db_path=str(tmp_path / "test.db"))
+ agent = mgr.create_from_template("research_monitor", "Test Agent")
+ config = agent["config"]
+ assert config.get("icon") == "🔬"
+ mgr.close()