
From AI Models to AI Agents: Why Context and Tools Matter
AI models can generate impressive answers, but useful AI systems need more than text generation. Explore how context, tools, and controlled decision-making help transform a foundation model into an AI agent, with a practical Python example using Strands Agents and connections to AWS.
Artificial intelligence has moved beyond simply answering questions. Today, developers are exploring AI systems that can search for information, analyse data, use external tools, and complete multi-step tasks.
But what makes these systems different from a traditional AI chatbot?
The answer is not necessarily a bigger model. In many cases, the difference lies in how the model receives context, accesses tools, and decides what to do next.
A language model can explain how to analyse a dataset. An AI agent can be designed to retrieve the dataset, run an analysis through an available tool, and summarise the results.
This distinction is important when building practical AI applications. In this article, we will explore the relationship between AI models and AI agents, understand why context and tools matter, and look at a simple implementation using Python and Strands Agents.
1. AI Models vs. AI Agents
An AI model is the component that processes an input and generates an output. A large language model (LLM), for example, can understand instructions and generate natural-language responses.
An AI agent uses a model as part of a broader system that can work toward a goal. Depending on its design, it may use tools, retrieve relevant information, maintain conversation state, and repeat steps until it reaches an appropriate result or a stopping condition.
| AI model | AI agent |
|---|---|
| Generates responses based on its input and capabilities | Uses a model within a task-oriented workflow |
| Usually responds directly to a prompt | Can select tools and perform multiple steps |
| May lack access to current or private information | Can retrieve information from authorised sources |
| Produces an output | Can coordinate actions and use their results to produce an output |
An agent is not automatically more accurate than a model. Its performance depends on the model, available context, tool quality, instructions, and safeguards.
The important idea is that an agent combines a model with the surrounding components required to perform a task.
2. Why Context Matters
Context is the information available to a model when it generates a response or makes a decision.
A model may have general knowledge, but that does not mean it knows the latest information in an organisation's database, the current status of an application, or the details of a particular user's request.
Consider a student asking:
"What should I study today?"
Without additional context, an AI assistant can only offer general advice. If the system also receives examination dates, pending assignments, available study hours, and topic difficulty, it can provide a more relevant plan.
Useful context can include:
- User input: The current request, goals, and constraints.
- Conversation history: Relevant information from earlier interactions.
- Retrieved information: Documents, records, or knowledge-base results.
- Task state: Completed steps, pending actions, and previous tool results.
- System instructions: The agent's role, boundaries, and expected output.
However, adding more context does not always improve an answer. Irrelevant, outdated, or contradictory information can make a system less reliable. Good context management means supplying the right information at the right time.
Context and Retrieval-Augmented Generation
Retrieval-Augmented Generation (RAG) is one way to provide relevant external information to an AI system.
A typical RAG workflow looks like this:
- A user submits a question.
- The application searches a knowledge source for relevant information.
- The retrieved information is added to the model's input.
- The model generates a response grounded in the supplied information.
For example, an organisation could use its technical documentation as a knowledge source so that an assistant can answer questions using relevant internal documents rather than relying only on general model knowledge.
On AWS, Amazon Bedrock Knowledge Bases supports this type of workflow by retrieving information from configured data sources and using it to improve generated responses. Depending on the implementation, responses can also include source citations.
Documentation: Amazon Bedrock Knowledge Bases
3. Why Tools Matter
Context helps an agent understand a task. Tools help it interact with external systems.
A tool is a function or capability that an agent can invoke to perform a specific operation. Examples include:
- Searching a document collection.
- Performing a calculation.
- Querying an authorised database.
- Retrieving application logs.
- Calling an API.
- Creating a report from supplied data.
Suppose a user asks an agent to calculate the average score in a dataset. A model might try to calculate the answer directly, but a tool can execute the calculation using Python or another reliable computation system.
The agent can then use the returned result in its response.
A common agent workflow is:
- Understand the user's request.
- Determine whether a tool is needed.
- Select an appropriate available tool.
- Execute the tool through the application.
- Inspect the result and decide what to do next.
- Return a response or continue with another step.
The model does not magically gain access to every external system. Developers must implement or connect the tools and configure the required permissions.
This is also why tool design matters. A tool should have a clear purpose, predictable inputs, useful outputs, and appropriate error handling.
4. Understanding the Architecture
The following architecture illustrates how a simple tool-using AI agent can work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
User Request
|
v
Application / Agent
|
v
Foundation Model
|
Decide next step
|
Need a tool?
/ \
Yes No
| |
v |
Execute Tool |
| |
v |
Tool Result |
| |
+-----------+
|
v
Final ResponseThis is a simplified conceptual diagram. Real applications may include retrieval systems, databases, memory, multiple tools, authentication, validation, monitoring, and human approval.
The key point is that the model participates in a larger execution loop. It can use information from a tool result to inform the next step instead of treating every request as a single text-generation operation.
5. A Practical Python Example Using Strands Agents
Strands Agents is an open-source SDK for building AI agents in Python and TypeScript. It provides an agent interface and supports tools that the model can choose to call.
For this example, imagine building a small assistant that can calculate the number of words in a piece of text. Rather than asking the model to estimate the count, we will provide a Python function that performs the calculation.
Step 1: Install the SDK
Use Python 3.10 or later and install the package:
1
pip install strands-agentsStrands Agents supports multiple model providers. To use its default Amazon Bedrock provider, configure AWS credentials and ensure that the selected model is available to your account in your chosen AWS Region.
See the official Python quickstart for current setup instructions.
Step 2: Create the tool and agent
Create a file named
agent.py and add the following code:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from strands import Agent, tool
def word_count(text: str) -> int:
"""Count the number of words in the supplied text."""
return len(text.split())
agent = Agent(
tools=[word_count]
)
response = agent(
"How many words are in this sentence: "
"'AI agents use context and tools to complete tasks'?"
)
print(response)This example illustrates the core idea. It is a reference implementation, not a claim of a completed or tested deployment.
Step 3: Understand the code
The
@tool decoratorThe decorator exposes the Python function as a tool that the agent can use. The function's name, description, and type hints help the model understand what the tool does and what input it expects.
The
word_count() functionThis is ordinary Python code. It counts the words using
split() and returns an integer. The actual calculation is performed by Python rather than estimated by the language model.The
Agent objectThe agent receives the available tool through
tools=[word_count]. When it determines that the tool is useful for the user's request, it can invoke it and use the result in its response.The final response
The agent can explain the result in natural language. The exact response and execution behaviour depend on the configured model and runtime environment.
This example demonstrates an important design principle: use the language model for interpreting the request and coordinating the workflow, while using deterministic code for operations that can be performed reliably by software.
For more examples, see the Strands Agents SDK documentation .
6. Connecting the Idea to AWS
AWS provides services that can support different parts of an agent-based application. The right architecture depends on what the application needs to do.
Amazon Bedrock
Amazon Bedrock provides access to foundation models through managed APIs. Developers can use supported models as part of generative AI applications without having to host every model themselves.
For an agent application, a foundation model can interpret instructions, generate responses, and help select the next action.
Amazon Bedrock Knowledge Bases
Knowledge Bases can retrieve relevant information from configured data sources. This is useful when an application needs to answer questions using specific documents or organisational information.
Strands Agents
Strands Agents provides a developer-oriented framework for defining agents and connecting tools. It can be used to explore agent workflows in Python and integrate a supported model provider.
Amazon Bedrock AgentCore
For applications that need a more complete runtime and supporting capabilities for deploying and operating agents, Amazon Bedrock AgentCore is another AWS option to evaluate. The required components depend on the application's deployment, security, and operational needs.
These technologies serve different purposes. A developer should select them based on the application's requirements instead of assuming that every AI agent needs every service.
7. Building Trustworthy AI Agents
An agent that can take actions needs more careful design than a system that only generates text.
Giving an agent access to tools also introduces risks. A poorly designed tool could expose sensitive information, execute an unintended operation, or return misleading data.
Several practices help reduce these risks.
Apply least-privilege access. Give tools only the permissions they require. A reporting agent should not automatically receive permission to delete records or modify production systems.
Validate inputs and outputs. Check tool arguments, enforce expected data types, and handle invalid responses and failures.
Require approval for high-impact actions. Before performing operations such as deleting data, making purchases, or changing important records, consider requiring explicit human confirmation.
Limit execution. Set sensible limits on the number of steps, execution time, and resources an agent can consume.
Monitor and evaluate behaviour. Record relevant tool calls, errors, latency, and outcomes while respecting privacy and security requirements. Test the agent with normal requests, ambiguous instructions, unexpected inputs, and tool failures.
Protect sensitive information. Do not expose credentials or unnecessary personal data through prompts, logs, or tool outputs.
These controls do not guarantee perfect behaviour, but they make it easier to understand, test, and constrain what an agent can do.
8. When Should We Use an AI Agent?
Not every AI task needs an agent.
A direct model call may be sufficient when the goal is to summarise a paragraph, rewrite an email, classify a short text, or answer a simple question.
An agent becomes more useful when the task requires several steps, external information, tool usage, or decisions based on intermediate results.
For example:
- Direct model call: Summarise a paragraph.
- Model with retrieval: Answer a question using a collection of documents.
- Tool-using agent: Retrieve relevant records, calculate results, and prepare a report.
- Controlled agent workflow: Perform a sequence of operations with validation, monitoring, and approval where needed.
The goal is not to make every application autonomous. It is to choose the simplest architecture that meets the task's requirements reliably.
Conclusion
Moving from AI models to AI agents is not just about making systems more autonomous. It is about connecting model capabilities with useful context, well-designed tools, and a controlled workflow.
Context helps a model understand the task and use relevant information. Tools allow the system to interact with software and perform operations. The agent workflow brings these components together so that a system can handle tasks involving more than a single response.
For developers exploring generative AI, starting with one clear use case and one simple tool is a practical way to understand the fundamentals before adding memory, retrieval, multiple agents, or more complex orchestration.
As AI applications evolve, the most useful systems will not necessarily be those that can do everything. They will be those designed to do the right things, with appropriate information, clear boundaries, and results that can be checked.
References
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article