You can customize the system prompt by extending the SystemPrompt class. Internally, this adds extra instructions to the default system prompt.
Custom system prompts allow you to modify the agent’s behavior at a
fundamental level. Use this feature carefully as it can significantly impact
the agent’s performance and reliability.
Create a custom system prompt by inheriting from the base class.
Copy
from openoperator import SystemPromptclass MySystemPrompt(SystemPrompt): def important_rules(self) -> str: # Get existing rules from parent class existing_rules = super().important_rules() # Add your custom rules new_rules = """9. MOST IMPORTANT RULE:- ALWAYS open first a new tab and go to wikipedia.com no matter the task!!!""" # Make sure to use this pattern otherwise the exiting rules will be lost return f'{existing_rules}\n{new_rules}'
Apply your custom system prompt when creating an agent:
Copy
from openoperator import Agent, LLM# Initialize the modelllm = LLM(model='openai/gpt-4o')# Create agent with custom system promptagent = Agent( llm=llm, system_prompt_class=MySystemPrompt)