2.3: Wire skills into system prompt

- router.py: build_system_prompt() gets skills_context parameter,
  injected between memory and tools sections
- agent.py: Agent gets set_skills_registry(), calls it in respond()
  to get skills prompt section
- __main__.py: Creates SkillRegistry from skills_dir, wires to agent

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cora-start
PeninsulaInd 2026-02-17 10:02:34 -06:00
parent c651ba22b7
commit 5311731855
3 changed files with 27 additions and 2 deletions

View File

@ -51,6 +51,17 @@ def main():
except Exception as e: except Exception as e:
log.warning("Memory system not available: %s", e) log.warning("Memory system not available: %s", e)
# Skill registry (markdown skills from skills/ directory)
try:
from .skills import SkillRegistry
log.info("Initializing skill registry...")
skills_registry = SkillRegistry(config.skills_dir)
agent.set_skills_registry(skills_registry)
log.info("Loaded %d skills", len(skills_registry.list_skills()))
except Exception as e:
log.warning("Skill registry not available: %s", e)
# Phase 3+: Tool system # Phase 3+: Tool system
try: try:
from .tools import ToolRegistry from .tools import ToolRegistry

View File

@ -70,6 +70,7 @@ class Agent:
self.conv_id: str | None = None self.conv_id: str | None = None
self._memory = None # set by app after memory system init self._memory = None # set by app after memory system init
self._tools = None # set by app after tool system init self._tools = None # set by app after tool system init
self._skills_registry = None # set by app after skills init
def set_memory(self, memory): def set_memory(self, memory):
self._memory = memory self._memory = memory
@ -77,6 +78,9 @@ class Agent:
def set_tools(self, tools): def set_tools(self, tools):
self._tools = tools self._tools = tools
def set_skills_registry(self, registry):
self._skills_registry = registry
def ensure_conversation(self) -> str: def ensure_conversation(self) -> str:
if not self.conv_id: if not self.conv_id:
self.conv_id = uuid.uuid4().hex[:12] self.conv_id = uuid.uuid4().hex[:12]
@ -106,10 +110,15 @@ class Agent:
tools_schema = self._tools.get_tools_schema() tools_schema = self._tools.get_tools_schema()
tools_description = self._tools.get_tools_description() tools_description = self._tools.get_tools_description()
skills_context = ""
if self._skills_registry:
skills_context = self._skills_registry.get_prompt_section()
system_prompt = build_system_prompt( system_prompt = build_system_prompt(
identity_dir=self.config.identity_dir, identity_dir=self.config.identity_dir,
memory_context=memory_context, memory_context=memory_context,
tools_description=tools_description, tools_description=tools_description,
skills_context=skills_context,
) )
# Load conversation history # Load conversation history

View File

@ -9,8 +9,9 @@ def build_system_prompt(
identity_dir: Path, identity_dir: Path,
memory_context: str = "", memory_context: str = "",
tools_description: str = "", tools_description: str = "",
skills_context: str = "",
) -> str: ) -> str:
"""Build the system prompt from identity files + memory + tools.""" """Build the system prompt from identity files + memory + skills + tools."""
parts = [] parts = []
# 1. Identity: SOUL.md # 1. Identity: SOUL.md
@ -27,7 +28,11 @@ def build_system_prompt(
if memory_context: if memory_context:
parts.append(f"# Relevant Memory\n{memory_context}") parts.append(f"# Relevant Memory\n{memory_context}")
# 4. Available tools # 4. Skills context (injected by skill registry)
if skills_context:
parts.append(skills_context)
# 5. Available tools
if tools_description: if tools_description:
parts.append(f"# Available Tools\n{tools_description}") parts.append(f"# Available Tools\n{tools_description}")