System prompt: giving the agent its job
The system prompt is the instruction text that goes to the model before every conversation; in a deep agent it is the system_prompt argument, and it sets the agent's role, rules and answer style.
Last updated: 29 Sep, 2026 · Deep Agents 0.7
Input context and the system prompt
The video treats the system prompt as the first kind of context engineering: giving the agent the right information and tools, in the right format, so it can do a task reliably. Some context arrives when the agent starts. That is the input context: the system prompt, memory files and skills, loaded on every run. Other context arrives while it runs, such as the user's message; later lessons cover runtime context, compressing long histories and isolating work in subagents.
The example sets a research assistant's prompt: specialize in scientific literature, always cite sources, and use subagents for parallel research on different topics. The prompt is loaded first on every call. The video's code follows, run on Groq with the model line swapped. The reply is long, so the page prints its first 700 characters:
from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model
agent = create_deep_agent(
model=init_chat_model("groq:openai/gpt-oss-120b", max_retries=6),
system_prompt=(
"You are a research assistant specializing in scientific literature. "
"Always cite sources. Use subagents for parallel research on different topics."
),
)
result = agent.invoke({"messages": [{"role": "user", "content": "What is deepagent?"}]})
print(result["messages"][-1].content[:700])**DeepAgent – a short definition** *DeepAgent* is a term that is used in two closely‑related ways in the AI literature and software ecosystem: | Meaning | What it refers to | Typical context | |---------|-------------------|-----------------| | **(1) Conceptual “deep‑learning‑based agent”** | An autonomous software entity (an *agent*) whose decision‑making policy is represented by a deep neural network. | Reinforcement‑learning (RL) research, robotics, game AI, recommendation systems. | | **(2) Specific open‑source library** | A Python package that provides a high‑level API for building, training, and evaluating deep‑RL agents. It wraps TensorFlow/Keras (or PyTorch) and implements popular
The agent has no search tool, so the whole answer comes from what the model learned in training; nothing in it was looked up. "Always cite sources" in a prompt cannot give an agent sources. Only a tool can, which is why the trip planner's prompt says "use only what search_travel returns".
system_prompt and the descriptions of its tools. Together with opt-in planning and shorter tool descriptions, this cut a default turn's input tokens by about two thirds. Write the instructions your agent needs.Comparing no prompt with a travel-planner prompt
Start trip.py with search_travel, the catalog tool from Tools: a travel search the agent can call. Everything below goes in the same file, under it. The loop below builds the agent twice, once with no system prompt and once with the planner's, and asks both the same question.
from langchain.tools import tool
CATALOG = {
"paris": {
"flight": ["Return flight Delhi to Paris: 42,000 rupees"],
"hotel": ["Seine Budget Inn, Latin Quarter: 5,200 rupees a night",
"Hotel Lumiere, Montmartre: 7,500 rupees a night",
"Le Grand Opera Hotel: 16,000 rupees a night"],
"sight": ["Eiffel Tower summit: 3,100 rupees", "Louvre Museum: 2,000 rupees",
"Seine river cruise: 1,500 rupees", "Versailles day trip: 2,600 rupees",
"Montmartre walking tour: free"],
"food": ["Cafe breakfast and bistro dinner: 3,000 rupees a day"],
},
}
@tool
def search_travel(city: str, kind: str) -> str:
"""Search the travel catalog. kind is "flight", "hotel", "sight" or "food". Prices are in rupees."""
entries = CATALOG.get(city.lower(), {}).get(kind)
return "\n".join(entries) if entries else f"The catalog has no {kind} entries for {city}."from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model
model = init_chat_model("groq:openai/gpt-oss-120b", temperature=0, max_retries=6)question = {"messages": [{"role": "user", "content": "Suggest two Paris sights that cost under 2,500 rupees."}]}
for prompt in [None, "You are a travel planner. Look up every price with search_travel and use only what it returns. Answer in two short sentences."]:
agent = create_deep_agent(model=model, tools=[search_travel], system_prompt=prompt)
result = agent.invoke(question)
tools_used = [c["name"] for m in result["messages"] for c in getattr(m, "tool_calls", [])]
print("system prompt:", "none" if prompt is None else "travel planner")
print("tools used: ", tools_used)
print("answer: ", result["messages"][-1].text, "\n")system prompt: none tools used: ['search_travel'] answer: Here are two great Paris attractions that fit comfortably within a ₹2,500 budget: | Sight | Approx. Cost (₹) | Why Visit? | |-------|------------------|------------| | **Louvre Museum** | **≈ 2,000 ₹** | Home to the world‑famous Mona Lisa, the Venus de Milo, and countless other masterpieces. You’ll get a full day of art, history, and culture in one of the world’s largest museums. | | **Seine River Cruise** | **≈ 1,500 ₹** | A relaxing boat ride that lets you see iconic landmarks—Eiffel Tower, Notre‑Dame, Musée d’Orsay—from the water. It’s a perfect way to soak up the city’s atmosphere without spending a lot. | Both options are well under the ₹2,500 limit and give you a memorable Paris experience. Enjoy your trip! system prompt: travel planner tools used: ['search_travel'] answer: The Louvre Museum costs about 2,000 rupees, and a Seine River cruise is around 1,500 rupees. Both offer memorable experiences without exceeding your budget.
What changed between the two runs
- Both agents called
search_travel. - Without a prompt the answer grew into a table with descriptions the catalog never returned, such as what each sight is famous for.
- With the prompt the answer kept to two sentences and to the catalog's prices, because the prompt said so.
Where the system prompt sits among the agent's context
| Context | Where it comes from | When the model sees it |
|---|---|---|
| System prompt | system_prompt= | Every call |
| Memory (AGENTS.md) | memory= | Every call, after the prompt |
| Skills | skills= | Names at start, full text when needed |
| Tool descriptions | Your tools and the built-ins | Every call |
What to put in a deep agent's prompt
- The agent's role and the task it serves: "You are a travel planner."
- Where facts must come from, and what to do when a tool finds nothing.
- The shape of the answer: length, format, and what files to write.
Related
- Previous: Built-in tools: files and the task tool
- Next: Streaming a deep agent's steps
- Reference: Customize Deep Agents: system prompt
- Add "Always give prices in euros too" to the planner's prompt and see what the agent does without an exchange rate.
- Ask the prompted agent about Tokyo and check it says the catalog has nothing.
- Give the video's research prompt to the travel agent and compare its answer.
Every expert started right here.