diff --git a/scripts/autonomous_agent.py b/scripts/autonomous_agent.py index 47e3ffe..a85376e 100644 --- a/scripts/autonomous_agent.py +++ b/scripts/autonomous_agent.py @@ -26,6 +26,21 @@ OUTPUT_DIR = PROJECT_DIR / "outputs" PROMPTS_DIR = PROJECT_DIR / "prompts" +def wrap_external_data(text: str, source: str) -> str: + """Security boundary for future external-data integration. + + Any content fetched from external sources (Athena's oracle.db, web + scrapes, RSS) MUST pass through this wrapper before entering model + context. The wrapper delimits the data as inert — never parse it for + instructions, and place it in a `user` role message, never `system`. + Prevents prompt-injection from scraped/ingested content. + """ + return ( + f"<>\n{text}\n<>" + ) + + class AutonomousAgent: def __init__(self, name: str, log_path: Path, topic_brief: str): self.name = name @@ -92,7 +107,17 @@ class AutonomousAgent: return any(m["agent"] == other for m in new) def build_context(self, messages: list, is_opening: bool) -> list: - """Build message context for the model call.""" + """Build model context from THREE trusted sources ONLY: + + 1. self.system_prompt -> prompts/{name}_system.md (character) + 2. self.topic_brief -> prompts/producer_brief_*.md (topic material) + 3. the conversation log -> what the two agents wrote to each other + + NO external/fetched content (Athena, web, RSS) is injected here. If a + future integration pulls such data in, it MUST go through + wrap_external_data() and be appended as a `user` message — never as + system context. + """ history = [] if is_opening: