feat: expand system_prompt_template with instruction on agent creation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jon Saad-Falcon
2026-03-27 11:28:18 -07:00
co-authored by Claude Sonnet 4.6
parent 043c86b321
commit ccea853e5e
2 changed files with 49 additions and 0 deletions
+9
View File
@@ -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 ─────────────────────────────────────────────
+40
View File
@@ -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()