Skip to main content
Engineers use phidata to build agents with memory, knowledge, tools and reasoning.

Example: Research Agent

Let’s create a research agent that can search the web, read the top links and write a report for us. We “prompt” the agent using description and instructions.
1

Create Research Agent

Create a file research_agent.py
research_agent.py
2

Run the agent

Install libraries
Run the agent
The description and instructions are converted to the system prompt and the input (e.g. Simulation theory) is passed as the user prompt.Use debug_mode=True to view the raw logs behind the scenes.

Capturing the Agent’s response in a variable

While Agent.print_response() is useful for quick experiments, we typically want to capture the agent’s response in a variable to either pass to the frontend, another agent or use in our application. The Agent.run() function returns the response as a RunResponse object.
By default stream=False, set stream=True to return a stream of RunResponse objects.

RunResponse

The Agent.run() function returns either a RunResponse object or an Iterator[RunResponse] when stream=True.

RunResponse Attributes