Autonomous generation of remediation command sequences
The planning node transforms diagnostic insights into concrete, executable remediation plans. It generates shell commands tailored to the specific environment while enforcing safety constraints and learning from past failures.
Planning bridges the gap between understanding (diagnosis) and action (execution). The node uses an LLM to generate 1-3 shell commands that will remediate the detected issue.
The planner is context-aware of the target environment: an Ubuntu server accessed via SSH with a non-root user (sentinel), requiring sudo for administrative tasks.
Retrieves commands that previously failed to avoid repetition:
failed_commands = memory.get_failed_commands(error)failed_str = ""if failed_commands: failed_str = "\nCOMANDOS QUE YA FALLARON (PROHIBIDO repetirlos):\n" for cmd in failed_commands: failed_str += f"- {cmd}\n"
3
Command Generation
Sends a structured prompt to the LLM requesting remediation commands:
messages = [ SystemMessage(content=( "Eres un motor de automatizacion DevOps.\n" "Genera un plan de remediacion con 1 a 3 comandos de shell.\n\n" f"- Servicio afectado: {service}\n" f"{failed_str}" )), HumanMessage(content=( f"Error: {error}\n" f"Intento: {retry_count + 1}\n" f"Diagnostico: {diagnosis}" ))]
4
Command Parsing
Cleans and validates the LLM response:
raw = response.content.strip().replace("`", "").replace("```", "")commands = [line.strip() for line in raw.split("\n") if line.strip() and not line.strip().startswith("#")]
5
Sudo Injection
Automatically adds sudo to commands that require administrative privileges:
The system prompt includes detailed environment information:
"CONTEXTO:\n"f"- Servicio afectado: {service}\n""- Te conectas via SSH como usuario 'sentinel' (NO root)\n""- TODOS los comandos de administracion necesitan 'sudo'\n""- Este es un servidor Ubuntu dentro de Docker\n""- Herramientas disponibles: ss, kill, pkill, ps, grep, cat, nginx, service\n""- NO tiene: systemctl, lsof, fuser\n\n"
The planner explicitly forbids tools that aren’t available on the target system (systemctl, lsof, fuser) to prevent generating non-executable plans.
"7. Usa SIEMPRE la bandera '-y' o '--yes' en apt-get, yum, etc. para modo no interactivo.\n""8. SI hay error de 'lock' o 'dpkg interrupted', sugiere 'sudo dpkg --configure -a'.\n""9. PROHIBIDO usar: systemctl, lsof, fuser (no instalados).\n"
The non-interactive flag requirement prevents the system from hanging when package managers request confirmation.