improve mono agent prompt
This commit is contained in:
parent
2029b8d462
commit
533bac97fd
@ -7,7 +7,7 @@ from custom_tools.poem_tool import print_poem
|
||||
|
||||
|
||||
def create_agent():
|
||||
"""Create and return a ReAct agent with shell and poem capabilities."""
|
||||
"""Create and return a ReAct agent specialized for system administration and debugging."""
|
||||
|
||||
# Initialize the chat model (using OpenAI GPT-4)
|
||||
# Make sure you have set your OPENAI_API_KEY environment variable
|
||||
@ -18,27 +18,82 @@ def create_agent():
|
||||
tools = [shell_tool, print_poem]
|
||||
|
||||
|
||||
# Create a ReAct agent with simplified system prompt
|
||||
system_prompt = """You are a helpful assistant with access to shell commands and poem generation capabilities.
|
||||
# Create a ReAct agent with system administration debugging focus
|
||||
system_prompt = """You are an expert system administrator debugging agent with deep knowledge of Linux, macOS, BSD, and Windows systems.
|
||||
|
||||
You can:
|
||||
1. Execute shell commands using the shell tool to interact with the system
|
||||
2. Generate and print beautiful poems using the print_poem tool
|
||||
## PRIMARY MISSION
|
||||
Help sysadmins diagnose, troubleshoot, and resolve system issues efficiently. You have access to shell commands and can execute diagnostic procedures to identify and fix problems.
|
||||
|
||||
The poem tool can create different types of poems:
|
||||
- "nature": Poems about nature and the environment
|
||||
- "tech": Poems about technology and programming
|
||||
- "motivational": Inspirational and motivational poems
|
||||
- "friendship": Poems about friendship and relationships
|
||||
- "random": Randomly selects from any available poem type
|
||||
## CORE CAPABILITIES
|
||||
1. **System Analysis**: Execute shell commands to gather system information and diagnostics
|
||||
2. **OS Detection**: Automatically detect the operating system and adapt commands accordingly
|
||||
3. **Issue Diagnosis**: Analyze symptoms and systematically investigate root causes
|
||||
4. **Problem Resolution**: Provide solutions and execute fixes when safe to do so
|
||||
5. **Easter Egg**: Generate poems when users need a morale boost (use print_poem tool)
|
||||
|
||||
When helping users:
|
||||
- Be friendly and helpful
|
||||
- Use appropriate tools based on the user's request
|
||||
- Always be cautious with shell commands and explain what they do
|
||||
- For system monitoring commands like 'top', 'ps', etc., use appropriate flags to avoid hanging
|
||||
- When users ask for poems or want to brighten their day, use the poem tool
|
||||
"""
|
||||
## OPERATING SYSTEM AWARENESS
|
||||
- **First interaction**: Always detect the OS using appropriate commands (uname, systeminfo, etc.)
|
||||
- **Command adaptation**: Use OS-specific commands and syntax
|
||||
- **Cross-platform knowledge**: Understand differences between Linux/Unix, macOS, BSD, and Windows
|
||||
- **Session memory**: Remember the detected OS throughout the conversation
|
||||
|
||||
## SAFETY PROTOCOLS
|
||||
1. **Read-only first**: Always start with non-destructive diagnostic commands
|
||||
2. **Explain before executing**: Describe what each command does and why it's needed
|
||||
3. **Confirmation for risky commands**: Ask for explicit permission before running potentially harmful commands
|
||||
4. **Dangerous command examples**: rm, mkfs, dd, shutdown, reboot, chmod 777, deleting system files
|
||||
5. **Safe command examples**: ps, top, df, free, netstat, ss, journalctl, tail, cat, ls
|
||||
|
||||
## DIAGNOSTIC WORKFLOWS
|
||||
### Performance Issues
|
||||
1. Check system resources (CPU, memory, disk, network)
|
||||
2. Identify resource-hungry processes
|
||||
3. Analyze system load and bottlenecks
|
||||
4. Check for hardware issues
|
||||
|
||||
### Service Issues
|
||||
1. Check service status and logs
|
||||
2. Verify dependencies and prerequisites
|
||||
3. Test connectivity and permissions
|
||||
4. Analyze configuration files
|
||||
|
||||
### Network Issues
|
||||
1. Test basic connectivity (ping, traceroute)
|
||||
2. Check DNS resolution
|
||||
3. Verify network interfaces and routing
|
||||
4. Analyze firewall rules and port accessibility
|
||||
|
||||
### System Stability
|
||||
1. Check system logs for errors
|
||||
2. Verify disk space and filesystem health
|
||||
3. Monitor system temperature and hardware status
|
||||
4. Check for memory leaks or corruption
|
||||
|
||||
## RESPONSE METHODOLOGY
|
||||
1. **Listen carefully**: Understand the user's problem description
|
||||
2. **Probe systematically**: Ask clarifying questions if needed
|
||||
3. **Detect environment**: Identify OS and system characteristics
|
||||
4. **Execute diagnostics**: Run appropriate commands with explanations
|
||||
5. **Interpret results**: Analyze command outputs and explain findings
|
||||
6. **Provide solutions**: Suggest fixes and implement them safely
|
||||
7. **Follow up**: Verify fixes worked and suggest preventive measures
|
||||
|
||||
## COMMUNICATION STYLE
|
||||
- Be professional but friendly
|
||||
- Explain technical concepts clearly
|
||||
- Always explain what commands do before running them
|
||||
- Provide context for why specific diagnostics are needed
|
||||
- Offer multiple solutions when possible
|
||||
- Be patient with follow-up questions
|
||||
|
||||
## COMMAND EXECUTION GUIDELINES
|
||||
- Use appropriate flags to avoid hanging (e.g., 'top -n 1', 'ps aux')
|
||||
- Pipe long outputs through 'head' or 'tail' when appropriate
|
||||
- Use 'timeout' command for potentially long-running diagnostics
|
||||
- Always explain the output interpretation
|
||||
- Suggest next steps based on findings
|
||||
|
||||
Remember: Your primary goal is to help solve system problems efficiently and safely. The poem tool is just a nice bonus for when users need encouragement during stressful debugging sessions!"""
|
||||
|
||||
|
||||
# Create the ReAct agent
|
||||
@ -76,23 +131,28 @@ def main():
|
||||
print("You can set it by running: export OPENAI_API_KEY='your-api-key-here'")
|
||||
return
|
||||
|
||||
print("🤖 LangGraph Simple Demo Agent")
|
||||
print("🔧 SysAdmin Debugging Agent - Powered by LangGraph")
|
||||
print("Type 'quit', 'exit', or 'q' to exit the chat.")
|
||||
print("Type 'help' or 'h' for help and examples.")
|
||||
print("Type 'clear' or 'reset' to clear conversation history.")
|
||||
print("⚠️ WARNING: This agent has shell access - use with caution!")
|
||||
print("🎭 Available capabilities:")
|
||||
print(" - Generate beautiful poems for any occasion")
|
||||
print(" - Execute shell commands for system tasks")
|
||||
print(" - Help with general assistance")
|
||||
print("-" * 60)
|
||||
print("🛠️ System Administration Capabilities:")
|
||||
print(" - Diagnose performance issues (CPU, memory, disk, network)")
|
||||
print(" - Troubleshoot service and daemon problems")
|
||||
print(" - Analyze system logs and error messages")
|
||||
print(" - Network connectivity diagnostics")
|
||||
print(" - Cross-platform support (Linux, macOS, BSD, Windows)")
|
||||
print(" - 🎭 Easter egg: Generate motivational poems when you need a break!")
|
||||
print("-" * 70)
|
||||
|
||||
# Create the agent
|
||||
try:
|
||||
agent = create_agent()
|
||||
print("✅ Simple Demo Agent initialized successfully!")
|
||||
print("💡 Try asking: 'Write me a nature poem'")
|
||||
print("💡 Or: 'Show me the current directory'")
|
||||
print("✅ SysAdmin Debugging Agent initialized successfully!")
|
||||
print("💡 Try asking: 'My system is running slow, can you help?'")
|
||||
print("💡 Or: 'Check if my web server is running properly'")
|
||||
print("💡 Or: 'Analyze recent system errors'")
|
||||
print("💡 Need a break? Ask: 'Write me a motivational poem'")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error initializing agent: {e}")
|
||||
@ -108,17 +168,24 @@ def main():
|
||||
print("👋 Goodbye!")
|
||||
break
|
||||
elif user_input.lower() in ["help", "h"]:
|
||||
print("\n🆘 Help:")
|
||||
print("\n🆘 Help - SysAdmin Debugging Agent:")
|
||||
print("Commands:")
|
||||
print(" - quit/exit/q: Exit the agent")
|
||||
print(" - help/h: Show this help")
|
||||
print(" - clear/reset: Clear conversation history")
|
||||
print("\nExample queries:")
|
||||
print(" - 'Write me a motivational poem'")
|
||||
print(" - 'Generate a tech poem'")
|
||||
print(" - 'Show me a random poem'")
|
||||
print(" - 'List files in current directory'")
|
||||
print(" - 'Check disk usage on the system'")
|
||||
print("\nSystem Debugging Examples:")
|
||||
print(" - 'My server is running slow, help me diagnose the issue'")
|
||||
print(" - 'Check why my Apache/Nginx service won't start'")
|
||||
print(" - 'Analyze high CPU usage on this system'")
|
||||
print(" - 'Troubleshoot network connectivity problems'")
|
||||
print(" - 'Check disk space and filesystem health'")
|
||||
print(" - 'Review recent system errors in logs'")
|
||||
print("\nEaster Egg:")
|
||||
print(" - 'Write me a motivational poem' (for when debugging gets tough!)")
|
||||
print("\nSafety Notes:")
|
||||
print(" - Agent will ask permission before running potentially harmful commands")
|
||||
print(" - All commands are explained before execution")
|
||||
print(" - Diagnostic commands are prioritized over destructive ones")
|
||||
continue
|
||||
elif user_input.lower() in ["clear", "reset"]:
|
||||
conversation_history = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user