To make the abstract ideas of agentic systems more concrete, let's walk through a simplified example of an AI agent performing a task. This exercise will help illustrate how the components discussed earlier, the LLM, tools, memory (even if basic), and prompts, work together. Our goal is to observe and understand the agent's decision-making process, even in a simulated environment.
Imagine a user asks our AI agent: "What is the capital of France, and what is its current population?"
This is a straightforward question, but it requires the agent to potentially perform multiple steps: identify the two pieces of information needed, retrieve them (likely using a tool), and then synthesize an answer.
For this demonstration, our agent is equipped with:
web_search(query: str)
tool: This tool allows the agent to look up information on the internet. It takes a search query as a string and returns a text snippet with the search results.To guide the agent's behavior and ensure it follows a structured approach, we provide it with a "master prompt" or a set of system-level instructions. This prompt outlines how the agent should think, act, and use its tools. It's a foundational piece of prompt engineering for agentic behavior.
Here's an example of such a master prompt, which encourages a ReAct-like (Reasoning and Acting) cycle:
You are an AI assistant. Your task is to answer the user's question accurately.
You have access to the following tool:
- web_search(query: string): Searches the internet for information based on the query and returns a summary.
To answer the question, follow these steps repeatedly:
1. Thought: Briefly explain your plan or the next step you will take.
2. Action: Specify the tool to use and the input to that tool. If you have the answer, state 'Final Answer:'.
3. Observation: Record the result from the tool.
Repeat steps 1-3 as needed until you can provide the final answer.
User Question: What is the capital of France and what is its current population?
This prompt explicitly tells the agent:
Thought
), tool usage (Action
), and processing of tool outputs (Observation
).Final Answer:
).Now, let's simulate the agent's internal monologue and actions as it processes the user's question, guided by the master prompt.
Iteration 1: Finding the Capital
web_search("capital of France")
web_search
tool is called. It queries a search engine and processes the results.)At this point, the agent has successfully retrieved the first piece of information. The "Observation" is now part of its working context.
Iteration 2: Finding the Population
web_search("current population of Paris")
web_search
tool is called again.)The agent has now retrieved the second piece of information.
Iteration 3: Synthesizing the Final Answer
Final Answer: The capital of France is Paris, and its current population is approximately 2.1 million.
The agent signals it has the complete answer, and the process concludes.
This simple execution trace reveals several important aspects of agentic systems:
web_search
tool. The master prompt's description of the tool was important for this.The agent's operation can be visualized as a sequence of states and transitions, driven by its internal reasoning and interactions with its tools.
Diagram illustrating the iterative thought-action-observation cycle of the agent for the information retrieval task.
This diagram shows how the agent cycles through thinking, acting (often involving a tool), and observing the outcome, updating its internal state or context until it can produce the final answer.
This hands-on analysis, though simplified, directly relates to the foundational topics of this chapter:
web_search
tool as an external capability, and the implicit use of short-term memory (context window) to link steps.Thought:
, Action:
, Observation:
format is a prompt-based mechanism.Thought -> Action -> Observation
cycle mirrors the core loop of agent architectures like ReAct, which we briefly introduced. This example provides a practical glimpse into how such architectures operate.By dissecting even a simple agent task, we begin to appreciate the interplay of different components and the significant role that careful prompt design plays. As we move through this course, we will build upon these basic principles to construct and manage more sophisticated agentic workflows.
Was this section helpful?
© 2025 ApX Machine Learning