Part II — Autonomy · Chapter 4

Agents: encapsulating autonomy and intelligence

~30 min read4 interactive widgets

In this chapter

  1. Decomposition, abstraction, encapsulation
  2. Four definitions of encapsulation
  3. The main question of intelligent systems engineering
  4. The answer: agents
  5. The many agents around
  6. Three key abstractions for MAS
  7. Agent and environment: perception and action
  8. Why a perceive–act cycle does not work
  9. Knowledge, representation, and keeping up with the world
  10. Reasoning about actions, and everything else
  11. The right place for intelligence
  12. Check your understanding

1. Decomposition, abstraction, encapsulation

Chapter 3 ended with a definition of agents built entirely out of autonomy. This chapter asks a different and, for an engineer, more urgent question: why should anyone care? The answer does not come from AI at all. It comes from the oldest set of principles software engineering has.

Decomposition and modularisation [Parnas, 1972]. When software systems grow too complex, decomposition makes it possible to articulate them as ensembles of distinct, interacting components. This is typically supported by modular programming languages, where language abstractions directly promote organisation in terms of well-defined components — modules, functions, procedures, objects, agents [Odell, 2002].

Abstraction. When complexity grows, abstraction is required too: the general cognitive process of taking away unnecessary details and focusing on the essence of something. Once a programming-language function implements a mathematical function in terms of its mathematical specification, no one cares any more about its implementation in terms of the programming language. Abstraction is coupled with hiding, which limits access to a well-defined range of the component’s features: function signatures, information hiding, visible versus hidden functions in modules, public/protected/private methods, interfaces, abstract classes.

Encapsulation is the simple yet essential principle that exploits both. Roughly speaking, encapsulation amounts to devising the main features of a software system, abstracting away from unnecessary details, and associating them with the modules into which the system is decomposed, hiding the implementation details.

Key idea

Note the order of the argument, because it determines everything that follows. Encapsulation is not introduced as a nice property of agents. It is introduced as the instrument for dealing with complexity — and agents are then proposed as the answer to the question “what should we encapsulate intelligence in?”. The agent is a means, not a fashion.

2. Four definitions of encapsulation

The deck gives four definitions in sequence, from four different communities. They are not redundant: each one adds a constraint the previous one left implicit, and reading them as a progression is the fastest way to see what changes when we get to agents.

Notice what all four have in common: something is put inside a container and the container is given a precise specification of what it offers. And notice what none of them mentions: control. In every one of these definitions, whoever calls the module decides when the module runs. That omission is exactly the gap Chapter 3 identified in object orientation, and it is why agents are not simply the next kind of module.

3. The main question of intelligent systems engineering

Basic software engineering principles and techniques such as modularisation, decomposition and abstraction deal with the complexity of software systems: the more systems grow complex, the more they matter. Encapsulation is essential for the engineering of complex software systems.

Now, intelligent systems are complex. Featuring intelligence obviously increases the complexity of software systems, so we expect the same general principles to be relevant for intelligent systems engineering too. But with a warning the deck marks explicitly: we can no longer expect to deal with those features at the mere programming-language level, possibly based on a single programming language. Existing heterogeneous AI technologies push towards multi-language, multi-paradigm settings.

So: how do we expect encapsulation to work for intelligent systems? What should drive abstraction, decomposition and modularisation there? The deck condenses it into the main question:

What are the suitable software abstractions to encapsulate the many techniques available for the many diverse issues requiring artificial intelligence?

Or, more generally: what is the right place for AI techniques in intelligent systems engineering?

This is the question Chapter 1 raised three times without answering: once we learn how to solve a specific problem with a specific AI technique, where do we put it? How do we combine heterogeneous techniques without ad hoc glue? How do we let a deployed system evolve in terms of intelligence — adding new, changing old intelligent components — without the composition becoming unmanageable?

4. The answer: agents

The deck labels this slide “spoiler alert”, and the reasoning is three lines long.

Agents are computational abstractions encapsulating everything — computational autonomy, for sure, so that they also work as our abstraction of choice for autonomy. Therefore they look like the obvious candidates to encapsulate intelligence, in its many diverse forms. And almost all scientific and technical communities have largely converged on that notion — though, the deck adds drily, not exactly on what an agent is, on what defines an agent.

For the exam

If asked “why agents?”, do not answer with a list of agent features. Answer with the argument: complexity requires encapsulation; intelligent systems are complex and heterogeneous, so they need something to encapsulate AI techniques into; agents already encapsulate control and state and everything else in principle; therefore agents are the natural container for intelligence, and consequently the basic bricks for engineering intelligent systems. The features come after.

That final parenthesis — nobody agrees on what an agent is — is not a throwaway. It is the subject of the next section, and it is genuinely useful: each community noticed a different thing about agents, and the union of those observations is a fairly complete requirements list.

5. The many agents around

The areas with their own notion of agent: artificial intelligence (AI), distributed artificial intelligence (DAI), agentic AI, parallel and distributed systems (P&D), mobile computing, programming languages and paradigms (PL), software engineering (SE), and robotics.

Encapsulating intelligence. Agents in AI have from the very beginning worked as the units encapsulating intelligence [Russell and Norvig, 2022] — specifically individual intelligence, within the symbolic interpretation of intelligence. AI agents are essentially cognitive agents: they are first cognitive entities, then active entities — in spite of their very name, coming from the Latin agens, the one who acts.

Overcoming the individual dimension [Wooldridge, 2009]. No more a single unit encapsulating individual intelligence and acting alone within an oversimplified environment. The social acceptation of agency: agents are individuals within a society of agents — components of a multi-agent system — and are distributed within a distributed environment. A DAI agent has an explicit representation of the world, is situated within its environment, solves a problem that requires intelligence, deliberates and plans its course of actions, is flexible, is adaptable, and learns [O’Hare and Jennings, 1996].

The five-step loop [Gullí, 2025]: get the mission (the agent is given a goal); scan the scene (it gathers contextual information to understand what is happening); think it through (it devises a plan of action by considering the best approach); take action (it executes the plan); learn and get better (it observes successful outcomes, understands the situation, possibly learns, then adapts accordingly). Chapter 3 discussed this loop; Chapter 11 dissects the architectures that implement it.

Autonomous in control. The complexity is in the control flow, and the need is to abstract away from control. An agent encapsulates control flow; an agent is an independent locus of control; an agent is never invoked — it merely follows and drives its own control flow. An agent is autonomous in control: it is never invoked because it cannot be invoked.

Mobile [Fuggetta et al., 1998]. An agent is not bound to the virtual machine where it is born. And the deck reverses the perspective in a line worth remembering: it is not that agents are mobile, it is that objects are not. Mobility is another dimension of computing, just uncovered by agents — and a new dimension requires new models, technologies and methodologies, to be used for reliability, limitations in bandwidth, fault tolerance.

Physical and situated. A robot is a physical agent: it has both a computational and a physical nature, so the complexity of the physical world enters the agent boundaries and cannot be confined within the environment. A robot is intrinsically situated: its intelligent behaviour cannot be considered separately from the environment where it lives and acts. Some intelligent behaviour can be achieved even without any symbolic representation of the world — the non-symbolic approach [Brooks, 1991] or situated action [Suchman, 1987] — and the reactive, layered, subsumption architecture [Brooks, 1986] comes from here.

An abstraction for engineering systems. It encapsulates complexity in terms of information and knowledge, control, goal and task, intelligence, and mobility. Hence agent-oriented software engineering (AOSE): engineering computational systems using agents, with agent-based methodologies and tools.

Autonomous and interactive. A MAS agent is goal- or task-oriented: it encapsulates control, and control is finalised to task or goal achievement; it pursues its goal proactively, not in response to an external stimulus. It has limited perception and limited capabilities, so it depends on other agents and external resources to achieve its goal, and needs to interact with them [Agre, 1995] through communication actions and pragmatic actions. It lives not in isolation, but within an agent society and immersed in an agent environment. And the open problem it raises: agents are goal-oriented, but so is the MAS as a whole — how do individual and global goals coexist fruitfully, without clashes?

AGENT one boundary, eight demands AI encapsulate intelligence PL locus of control robotics physical, situated DAI social, distributed P&D mobile SE an abstraction, AOSE agentic AI the five-step loop MAS autonomous and interactive
Plate 4.1 — Eight communities, one abstraction. The arrangement is the editor’s; the eight notions are the deck’s. Read the arrows as requirements arriving at the same boundary: the reason agents are the right container is that all eight demands can be met inside a single one.

6. Three key abstractions for MAS

The survey collapses into a short list. The basic abstractions for MAS engineering are agents, society and environment.

Three, not one. The point is easy to skim past and it structures the remainder of Module 1: the agent is not sufficient on its own, because a MAS agent has limited perception and limited capabilities, depends on other agents and on external resources, and lives immersed in an environment. Chapter 11 will make the third abstraction concrete by giving the environment its own first-class inhabitants — artefacts — and Chapter 12 will show both society and environment as running code, in the shape of platforms and their infrastructure services.

7. Agent and environment: perception and action

With the abstraction chosen, the deck starts filling it. Two capabilities come first, and they are stated as survival requirements rather than as features.

Perception. To first survive and then possibly behave intelligently, an agent should be aware of its situation, of the context it is immersed in: perceiving the state of the world around and its dynamics — its changes over time — through sensors, in order to build its own representation of the world.

Action. To survive and possibly behave intelligently, an agent should be able to affect the world around it, acting to change it through its actuators, or effectors, based on its own representation of the world, to possibly perform some task or achieve some goal.

AGENT(s) ENVIRONMENT actions through actuators perception through sensors THE SIMPLEST AGENT The two arrows are the whole of it. Everything the rest of the chapter adds happens inside the top box.
Plate 4.2 — The simplest agent, redrawn from the deck. Deceptively small: the diagram says nothing about how the top box gets from the blue arrow to the red one, and that gap is the subject of the next four sections.

8. Why a perceive–act cycle does not work

Here is the most important negative result in the chapter, and it is the reason agent architectures are not trivial.

An agent should be at the same time:

Therefore a working cycle where perception and action simply follow one another just does not work in general — exception made for trivial agents, such as the thermostat. An agent architecture should structurally solve the duality between reactivity and proactivity, so that the solution to the proactive/reactive dichotomy is encapsulated within the agent abstraction too.

For the exam

This is a favourite: why is a simple perceive–act loop not enough? The answer is not “because it is slow” or “because it lacks memory”. It is that the two required behaviours are in tension. A fully reactive agent abandons whatever it was pursuing every time the world twitches; a fully proactive agent commits to a plan and stops noticing the world. The architecture has to hold both at once, which is why Chapter 7 spends its length on control loops and Chapter 12 shows a real interpreter interleaving events and intentions.

Watch out

The thermostat is named by the deck as the exception, and it is a useful sanity check rather than a joke. If your “agent” can be written as a single loop of read-sensor, apply-rule, write-actuator, then you have a purely reactive component, and the whole apparatus of goals, plans and deliberation buys you nothing. Chapter 7 gives the same example under a precise definition: purely reactive agents decide what to do without reference to their history.

9. Knowledge, representation, and keeping up with the world

An intelligent agent should encapsulate knowledge about the world, possibly including the current state of the environment, the events determining its evolution, and the laws regulating its dynamics. In doing so it structurally faces the many issues of knowledge representation and maintenance:

Overall, then, it should also encapsulate the ability of reactive reasoning about knowledge. Chapters 8 and 9 supply the machinery for the last two bullets in particular; this chapter only insists that the machinery has to live inside the agent boundary.

Perception versus representation

Then comes a problem that has no clean solution and that the deck states with unusual care. The environment changes over time, either by agent actions or by its own dynamics, and an intelligent agent needs to keep on perceiving and interacting with it. Yet — even assuming that an agent could potentially observe all the relevant changes — it should not spend all of its time monitoring the environment and updating its internal representation of the world; instead, it should do something.

Which raises the question: how, and to what extent, can an agent rely upon the fact that its knowledge about the world is at any time up to date and consistent with the current state of the world itself? An intelligent agent should generally ensure that its internal representation somehow matches the current state of the world — so that the perception-versus-representation issue is itself dealt with and encapsulated within the agent.

Key idea

Two impossible demands, held together by a budget. The agent must know enough about the world to act well, and must not spend its life finding out. Every architecture in the rest of this course is, among other things, a particular answer to that trade-off: BDI answers it with a belief revision function and a plan library (Chapter 7); classical planning answers it by assuming the world holds still (Chapter 10); reactive planning answers it by sensing at every step; and agentic AI answers it with memory and retrieval treated as tools (Chapter 11).

10. Reasoning about actions, and everything else

Once an agent has something to do or to achieve, it can exploit its own knowledge about the world to reason about what to do, and possibly plan its own course of actions. This requires at least some procedural knowledge about its own ability to act and affect the world:

So an intelligent agent should also encapsulate knowledge about actions, practical reasoning, planning and the like. Note the second bullet in passing: which tools are available to the agent. It is the only appearance of tools in this deck, and Chapter 11 turns it into a whole theory.

Plans procedural knowledge Beliefs factual knowledge Reasoning Perception Action BASIC REASONING AGENT — everything inside one boundary
Plate 4.3 — The basic reasoning agent, redrawn from the deck. Plans represent procedural knowledge about available actions; beliefs represent factual knowledge about the world. This picture is the direct ancestor of the BDI architecture of Chapter 7 and of the Jason belief base and plan library of Chapter 12.

And so on, and so forth

The deck then stops enumerating and gestures at the rest, which is the point of the whole exercise. An intelligent agent is meant to encapsulate: machine learning techniques, to improve its knowledge about the world and its ability to act intelligently; natural language processing capabilities, to make its interaction within socio-technical systems effective towards humans, animals and other artificial agents; spatial reasoning techniques, along with physical mobility, to gain the ability to move safely and effectively in a physical context; and so on, and so forth.

ENVIRONMENT AND SOCIETY: the other two key abstractions agent boundary — control does not cross it goal or task: the criterion governing control knowledge and reasoning planning machine learning NLP spatial reasoning practical reasoning and so forth AI techniques as pluggable blocks: this is the layer that must be able to evolve Read outside in: autonomy defines the boundary, the criterion governs the control inside it, knowledge and reasoning fill it, and the AI techniques plug into the innermost layer. Adding or replacing a technique must not disturb the layers above it. That is the whole promise.
Plate 4.4 — What an agent encapsulates, drawn as nested layers. The layering is the editor’s way of holding the deck’s list together; the contents of each layer are the deck’s. The vermilion blocks are the answer to the main question of section 3: this is the right place for AI techniques.

11. The right place for intelligence

The conclusion of the deck, in four lines that summarise Part II of this study path:

And two questions left deliberately open, which are the hinges to Part III: yet, what is intelligence, exactly? And how does intelligence connect with autonomy — in general, and within agents?

Editor’s note

It is worth pausing on how little has been assumed to get here. No commitment to symbolic AI, none to machine learning, none to a particular architecture. The claim is structural: whatever intelligence turns out to be, it will be built out of heterogeneous techniques that must be composed, evolved and replaced — and that is an encapsulation problem before it is an AI problem. Chapter 5 now goes looking for what intelligence is, and comes back with an answer that has nothing to do with reasoning.

Check your understanding

What is encapsulation, and how does it relate to decomposition and abstraction?

Encapsulation exploits both. Decomposition and modularisation articulate a complex system into distinct interacting components [Parnas, 1972]; abstraction takes away unnecessary details and focuses on the essence, coupled with hiding, which limits access to a well-defined range of features. Encapsulation amounts to devising the main features of a system, abstracting away from unnecessary details, and associating them with the modules into which the system is decomposed, hiding the implementation details.

Give the four definitions of encapsulation used in the deck.

As a process (modular languages, Parnas): the act of enclosing one or more items within a physical or logical container. In programming languages: a property providing mechanisms and abstractions allowing systems to be modularised around distinct components with limited interaction. In object-oriented programming: mechanisms to rule access to an object’s components, and constructs promoting the bundling of data with the methods operating on them. In software engineering [IEEE Std 610.12-1990]: a technique consisting of isolating a system function or a set of data and operations on those data within a module, and providing precise specifications for the module.

What is “the main question” of intelligent systems engineering?

What are the suitable software abstractions to encapsulate the many techniques available for the many diverse issues requiring artificial intelligence — or, more generally, what is the right place for AI techniques in intelligent systems engineering? It arises because intelligent systems are complex, because the same complexity-handling principles should therefore apply, and because heterogeneous AI technologies push towards multi-language, multi-paradigm settings where the programming-language level alone is no longer enough.

Reconstruct the argument for choosing agents.

Complexity requires encapsulation; intelligent systems are among the most complex software systems; agents are computational abstractions encapsulating everything — computational autonomy for sure, hence they are already our abstraction of choice for autonomy; therefore they are the obvious candidates to encapsulate intelligence in its many diverse forms; therefore agents work as the basic bricks for the engineering of intelligent systems. Almost all communities converged on the notion — though not on what exactly defines an agent.

What does each discipline see when it looks at an agent?

AI: the unit encapsulating individual, symbolic intelligence; a cognitive entity first, an active one second. DAI: an individual within a society, distributed in a distributed environment, with an explicit world representation, situated, deliberating, flexible, adaptable, learning. PL: an independent locus of control that is never invoked. P&D: a mobile entity not bound to the VM where it is born. Robotics: a physical and intrinsically situated agent, possibly without symbolic representation. SE: an abstraction encapsulating information, control, goal, intelligence and mobility — hence AOSE. MAS: an autonomous, proactive, interactive entity with limited perception and capabilities, living in a society and an environment. Agentic AI: the five-step loop.

“It is not that agents are mobile, it is that objects are not.” What does this reversal mean?

That mobility is not an exotic feature bolted onto agents but a dimension of computing that agents merely uncovered [Fuggetta et al., 1998]. The usual framing treats immobility as the default and mobility as the anomaly; the deck reverses the burden of proof. And it draws the engineering consequence: a new dimension requires new models, technologies and methodologies, to be used for reliability, bandwidth limitations and fault tolerance.

What are the three key abstractions for MAS engineering?

Agents, society and environment. Three, not one, because a MAS agent has limited perception and limited capabilities and therefore depends on other agents and on external resources for the achievement of its goal, needing to interact with both.

Why does a working cycle of perception followed by action not work in general?

Because an agent should be at the same time fully reactive (sensing environment changes and behaving accordingly) and fully proactive (deliberating on its own course of actions based on its internal representation). A cycle in which perception and action simply follow one another cannot deliver both — except for trivial agents such as the thermostat. The agent architecture must structurally solve the duality, so that the solution to the proactive/reactive dichotomy is itself encapsulated within the agent abstraction.

Which knowledge-representation issues must an intelligent agent face structurally?

Choosing the right KR language or formalism; getting access to all relevant knowledge and events; ignoring non-relevant information; dealing with conflicting data; possibly inferring new knowledge. Overall the agent should also encapsulate the ability of reactive reasoning about knowledge, and its knowledge should possibly include the current state of the environment, the events determining its evolution, and the laws regulating its dynamics.

State the perception-versus-representation problem.

The environment changes over time, either through agent actions or through its own dynamics, so the agent must keep perceiving. Yet even if it could observe all relevant changes, it should not spend all of its time monitoring the environment and updating its representation — it should do something. Hence the open question: how, and to what extent, can an agent rely on its knowledge being up to date and consistent with the current state of the world? The agent should ensure its internal representation somehow matches the world, and this issue too must be encapsulated within the agent.

What procedural knowledge does reasoning about actions require?

Which actions the agent can perform; which tools are available to it; how they can be combined; and how they could change the state of the environment. On that basis the agent can reason about what to do and possibly plan its course of actions, so it must encapsulate knowledge about actions, practical reasoning, planning and the like.

In the basic reasoning agent, what do plans and beliefs represent?

Plans represent procedural knowledge about available actions; beliefs represent factual knowledge about the world. Both feed a reasoning core that sits between perception coming in and action going out. It is the direct ancestor of the BDI architecture.

What else is an intelligent agent meant to encapsulate, beyond knowledge and planning?

Machine learning techniques, to improve its knowledge about the world and its ability to act intelligently; natural language processing capabilities, to make its interaction within socio-technical systems effective towards humans, animals and other artificial agents; spatial reasoning techniques, along with physical mobility, to move safely and effectively in a physical context; and so on and so forth — the open-endedness being precisely the point, since the abstraction has to survive the arrival of techniques nobody has invented yet.