System Message
Customize the agent's system message and role.
1"""2System Message3=============================45Customize the agent's system message and role.6"""78from kern.agent import Agent9from kern.models.openai import OpenAIResponses1011# ---------------------------------------------------------------------------12# Create Agent13# ---------------------------------------------------------------------------14agent = Agent(15 model=OpenAIResponses(id="gpt-5.2"),16 # Override the auto-generated system message with a custom one17 system_message="You are a concise technical writer. Always respond in bullet points. Never use more than 3 sentences per bullet point.",18 # Change the role of the system message (default is "system")19 system_message_role="system",20 markdown=True,21)2223# ---------------------------------------------------------------------------24# Run Agent25# ---------------------------------------------------------------------------26if __name__ == "__main__":27 agent.print_response(28 "Explain how HTTP cookies work.",29 stream=True,30 )Run the Example
1# Clone and setup repo2git clone https://github.com/kern-ai/kern.git3cd kern/cookbook/02_agents/03_context_management45# Create and activate virtual environment6./scripts/demo_setup.sh7source .venvs/demo/bin/activate89python system_message.py