I have a subagent as defined below where I provide a name for the agent.
# agent_weather.py
from langchain.agents import create_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}! There is no wind, temperature is 72 F, slight change of rain."
agent = create_agent(
name="weather-agent",
model="openai:gpt-5.4-mini",
tools=[get_weather],
system_prompt="You are a helpful weather forecast agent",
)
The subagent is utilized by the deep agent that is defined next. Notice the code for the deep agent also provides a name and description for the subagent.
# agent.py
from deepagents import create_deep_agent, CompiledSubAgent
from agent_weather import agent as agent_weather
from agent_divider import agent as agent_divider
def main():
"""Run the main agent."""
weather_subagent = CompiledSubAgent(
name="weather-subagent",
description="Specialized agent for weather forecasts",
runnable=agent_weather,
)
agent = create_deep_agent(
model="openai:gpt-5.4-mini",
system_prompt="You are a helpful assistant that uses subagents for specialized tasks",
subagents=[weather_subagent],
)
result = agent.invoke(
{
"messages": [
{
"role": "user",
"content": "Get the weather in paris",
}
]
}
)
print("\n--- Result ---\n", result)
text = result["messages"][-1].content[0]["text"]
print("\n--- Text ---\n", text)
So where should I define the name and description of the subagent in this code? Should it be in the subagent code itself or in the deep agent code or both?