From add11ee6c1aef9f3c5e20f681997f13299ee2b12 Mon Sep 17 00:00:00 2001 From: sylvain Date: Sun, 15 Mar 2026 19:48:51 +0000 Subject: [PATCH] feat: script command routing + LLM slot acquisition in base_agent - Add _handle_script_command() to bypass LLM and call script skill directly - Add 'script' to _handle_system_command routing - Add _llm_slot_acquire() / _llm_slot_release() MQTT semaphore for Ollama coordination Co-Authored-By: Claude Sonnet 4.6 --- agents_core/base_agent.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/agents_core/base_agent.py b/agents_core/base_agent.py index ce1c3f7..d90bf45 100644 --- a/agents_core/base_agent.py +++ b/agents_core/base_agent.py @@ -559,12 +559,37 @@ class BaseAgent(ABC): all_agents = [a.agent_id for a in self.registry.all_agents()] return f"Agents en ligne : {online}\nAgents connus : {all_agents}" + if cmd == "script": + return self._handle_script_command(args, source_msg) + if cmd == "update": return self._do_self_update(source_msg) # Commandes custom de l'agent return self.handle_custom_command(cmd, args, source_msg) + # ────────────────────────────────────────────── + # Commande script directe (bypass LLM) + # ────────────────────────────────────────────── + + def _handle_script_command(self, args: str, source_msg: Optional[Message] = None) -> str: + """ + Exécute une commande script sans passer par le LLM. + args : 'exec [args]' | 'list' | 'show ' | 'run | ' + """ + context = AgentContext(self) + result = self.skills.run("script", args, context) + if result is None: + result = f"[{self.agent_id}] Skill 'script' non disponible." + + # Renvoi MQTT si la commande vient d'un autre agent + if source_msg and source_msg.reply_to: + try: + self.mqtt.reply(source_msg, result) + except Exception as e: + logger.debug(f"[Script] Impossible d'envoyer la réponse : {e}") + return result + # ────────────────────────────────────────────── # Mise à jour self # ──────────────────────────────────────────────