A system prompt is an instruction message that sets an LLM’s high-level behavior for a request. In a chat API, it appears as a message with the system role alongside messages containing the user’s request. For example, a system message can say “You are a helpful assistant,” while the user message asks for a phishing reminder. section 2.1.2
Use a system prompt to define the assistant’s job, but put task-specific information where the model can use it. A Q&A request, for instance, can include a question and retrieved context; the instructions can require the answer to use that context and admit when it is insufficient. Clear wording matters: a prompt that merely asks a question may leave too much room for an unsupported answer. section 6.1.1 section 6.3.2
When drafting instructions, choose the parts the task needs:
- State the role and action: what should the assistant do with the input? section 2.6
- Supply relevant context, constraints, and processing steps rather than relying on the model to fill gaps. section 2.6 section 1.4.2
- Specify the output when it matters. A classification prompt improved when it requested only the category instead of an explanation. section 2.4.1
Guide an agent toward its tools
Suppose an agent must suggest beach towns with good weather. A system message tells it to use its tools for the information it needs, including town names. With descriptions of the travel-search and weather tools, the agent searches for candidate towns, checks forecasts, and can check more candidates when the first forecasts disappoint. The instruction is practical guidance, not a reason to assume every agent response will be reliable without inspection. section 11.8.2
Listing 11.11 Guiding tool selection
def llm_node(state: AgentState): #1
"""LLM node that decides whether to call the search tool."""
current_messages = state["messages"] #2
system_message = SystemMessage(content="""You are a helpful assistant
that can search travel information and get the weather forecast.
Only use the tools to find the information
you need (including town names).""") #3
current_messages.append(system_message) #4
response_message = llm_with_tools.invoke(
current_messages) #5
return {"messages": [response_message]} #6
The agent-node listing shows where a SystemMessage is added to the message list before the tool-enabled LLM is invoked. section 11.8.2
A system prompt can also set a narrow decision rule. In a multi-agent workflow, a router receives the user message with instructions to classify it as travel information or accommodation booking. Its structured result selects which specialist agent runs next. Keep that routing instruction separate from the specialist’s work: the router’s job is to choose a destination, not answer the request. section 12.2.2

















































