Tools vs Agents: A Mathmatical Representation
Tools are the building blocks of agentic applications. They allow for large language models to interact with external systems and take real world actions. Agents are the embodiment of intelligence, combining tools and data to achieve a specific goal. In this guide, we will explore the differences between tools and agents, their roles, and how they can be used together to create more powerful and intelligent applications.
Tools vs Agents
Tools are functions that can be called by a language model to perform specific tasks. Think of a tool as a function that takes input, performs a specific action, and returns output.
Tools can be expressed as a stateless function using the mathematical model f(x) = y
, where x
is the input and y
is the output. Obviously tools can take any complex object for input x
and return any complex object for output y
. An example of a tool is a calculator that can perform basic arithmetic operations.
Agents, on the other hand, are more complex and can be thought of as a state machine, modeled as f(x, s_x) = y, s_(x+1)
, where x
is the input, s
is the state, and y
is the output. This internal state allows the agents to remember and update their behavior over time. An example of an agent is a chatbot that can engage in conversation with users.
Strengths of Tools
- simple to implement
- easier to unit test
- passive autonomy
Strengths of Agents
- dynamic behavior
- active autonomy
- internal state
- self improvement
- task delegation and negotiation
Choosing to use Tools or Agents
The decision to choose between tools and agents depends on the type of interaction. If the input is fully known at the time of invocation, then a tool is the best choice. For example, when you perform a google search, you know the search query when you run the tool.
If the input is not fully known, then an agent is the better choice. Because the agent has an internal state, you can negotiate to achieve the desired outcome. For example, when you want to book a flight, but you do not know if the flight is available, you can negotiate with the agent to find a flight that meets your needs.
Examples of Tools vs Agents
Concept | Tool | Agent |
---|---|---|
PDF Summarization | complete document passed to summarizer with summary as output | Interactive q/a about document |
Image Captioning | image passed to captioner with caption as output | Interactive q/a about image |
Text Generation | prompt passed to generator with generated text as output | Multi Turn Interactive Conversation |
Task Delegation | single task passed to delegate with task result as output | Negotiate with agent to achieve task |
Composition of tools.
Since tools are modeled as mathematical functions, they can be composed together to create more complex tools. For example, a search tool and a summarization tool can be combined to create a tool that can summarize a search result.
This entire process can be modeled as a single function f(x) = y
, where x
is the input and y
is the output, where x is the search query and y is the summary.
Summary
Tools are simple to implement and can be unit tested. They are passive autonomous and do not require internal state. Agents are more complex and require internal state, but they can be more dynamic and self-improving. The choice between tools and agents depends on the type of interaction required and the input.