Introduction Message

Use the introduction parameter to set an initial greeting message.

1"""
2Introduction Message
3=============================
4
5Use the introduction parameter to set an initial greeting message.
6"""
7
8from kern.agent import Agent
9from kern.models.openai import OpenAIResponses
10
11# ---------------------------------------------------------------------------
12# Create Agent
13# ---------------------------------------------------------------------------
14agent = Agent(
15 model=OpenAIResponses(id="gpt-5.2"),
16 # The introduction is sent as the agent's first message in a conversation
17 introduction="Hello! I'm your coding assistant. I can help you write, debug, and explain code. What would you like to work on?",
18 markdown=True,
19)
20
21# ---------------------------------------------------------------------------
22# Run Agent
23# ---------------------------------------------------------------------------
24if __name__ == "__main__":
25 # The introduction message is available as a property
26 print("Introduction:", agent.introduction)
27 print()
28 agent.print_response(
29 "Help me write a Python function to check if a string is a palindrome.",
30 stream=True,
31 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/03_context_management
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python introduction_message.py