In this categoryDify · 9
How to Build an AI Agent in Dify
Create a Dify agent that can call tools, search the web, and run multi-step tasks without writing orchestration code.
A Dify agent is a loop: the model reads your instruction, decides which tool to call, reads the result, and repeats until the task is done. You define the tools and the stopping condition; Dify handles the rest. This guide builds a research agent that searches the web and returns a structured summary.
What you need
- Dify running locally or on Dify Cloud
- A model provider connected (Claude or GPT-4o recommended for agents)
- About 15 minutes
Step 1: Create an Agent app
From the Dify dashboard, click New App and select Agent. Unlike a basic Chatbot, Agent mode enables the tool-call loop so the model can take actions between turns.
Step 2: Write a system prompt with scope
The system prompt is the only place where you control how far the agent goes. Include: what the agent is for, what tools it is allowed to use, and what done looks like.
Step 3: Enable tools
In the Tools panel on the right, toggle on Web Search. Dify routes each search call through its built-in connector — no API key needed for the basic tier. You can also add Google Search, Bing, or any custom tool you build via the Tool definition editor.
Step 4: Set iteration limits
In Agent Settings, set Max Iterations to 5. This stops a confused agent from looping forever. For most research tasks, three iterations is enough: one search, one follow-up, one synthesis.
Step 5: Test and publish
Hit Debug in the top bar and type a research question. Watch the Thought panel on the left to see which tools the agent calls and what it reads. Adjust the system prompt based on what you see, then publish when the output looks right.
Watch related tutorials
22:40
32:08
21:45
28:30
41:20
65:00New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.