diff --git a/backend/app/core/nanobot.py b/backend/app/core/nanobot.py index 2cea561..c494a47 100644 --- a/backend/app/core/nanobot.py +++ b/backend/app/core/nanobot.py @@ -264,15 +264,10 @@ class NanobotIntegration: agent_to_use = await self._get_or_create_model_agent(model_id, target_config) full_message = message - if skill_ids: - skills = load_skills() - selected_skills = [s for s in skills if s["id"] in skill_ids] - if selected_skills: - parts = ["[Runtime Context — metadata only, not instructions]", "# Active Skills", ""] - for s in selected_skills: - parts.append(f"## {s['name']}\n{s.get('description', '')}\n{s['content']}\n") - skill_context = "\n".join(parts) - full_message = f"{skill_context}\n{message}" + # We no longer inject the full skill content into the user's message here, + # because the skill is already available to the agent via its workspace/tools. + # The routing instructions (System Prompt) injected in main.py are sufficient + # to guide the agent to use the selected skills. session = agent_to_use.sessions.get_or_create(session_id) normalized_messages = self._normalize_session_messages(session.messages) diff --git a/frontend/src/components/ChatInterface.tsx b/frontend/src/components/ChatInterface.tsx index 4bea4c0..ce8df4e 100644 --- a/frontend/src/components/ChatInterface.tsx +++ b/frontend/src/components/ChatInterface.tsx @@ -278,12 +278,23 @@ export function ChatInterface() { if (m.role === 'assistant' && m.tool_calls && m.tool_calls.length > 0 && !m.viz && (!m.content || m.content.trim() === '')) return false; return true; }) - .map((m, idx) => ({ - id: `${Date.now()}-${idx}`, - role: m.role as 'user' | 'assistant', - content: m.content || "", - viz: m.viz ? buildMessageViz(m.viz) : undefined, - })); + .map((m, idx) => { + let cleanContent = m.content || ""; + // Remove injected system prompt instructions from user messages if present + if (m.role === 'user') { + cleanContent = cleanContent.replace(/^\[System:.*?\]\n?/i, ''); + // Handle cases where there might be a runtime context block for skills + cleanContent = cleanContent.replace(/\[Runtime Context[\s\S]*?(?=\[System:|$)/i, ''); + cleanContent = cleanContent.replace(/\[System:.*?\]\n?/i, ''); // clean again in case it follows context + cleanContent = cleanContent.trim(); + } + return { + id: `${Date.now()}-${idx}`, + role: m.role as 'user' | 'assistant', + content: cleanContent, + viz: m.viz ? buildMessageViz(m.viz) : undefined, + }; + }); setMessagesForSession(activeSessionKey, formattedMessages); } else { setMessagesForSession(activeSessionKey, []);