What is an AI Agent

What is an AI Agent?

You've probably used an LLM like Gemini before, where you give it a prompt and it gives you a text response.

1
Prompt -> LLM -> Text

An AI Agent takes this one step further. An agent can think, take actions, and observe the results of those actions to give you a better answer.

1
Prompt -> Agent -> Thought -> Action -> Observation -> Final Answer

Define your agent

Now, let's build our agent. We'll configure an Agent by setting its key properties, which tell it what to do and how to operate.

These are the main properties we'll set:

  • name and description: A simple name and description to identify our agent.
  • model: The specific LLM that will power the agent's reasoning. We'll use "gemini-2.5-flash-lite".
  • instruction: The agent's guiding prompt. This tells the agent what its goal is and how to behave.
  • tools: A list of tools that the agent can use. To start, we'll give it the google_search tool, which lets it find up-to-date information online.
1
2
3
4
5
6
7
8
9
10
11
12
root_agent = Agent(
name="helpful_assistant",
model=Gemini(
model="gemini-2.5-flash-lite",
retry_options=retry_config
),
description="A simple agent that can answer general questions.",
instruction="You are a helpful assistant. Use Google Search for current info or if unsure.",
tools=[google_search],
)

print("✅ Root Agent defined.")

The big takeaway is that your agent didn't just respond—it reasoned that it needed more information and then acted by using a tool. This ability to take action is the foundation of all agent-based AI.

PS:Orchestrator(编排器)