Lecture
Software architecture is the foundation on which any digital solution is built. It defines not individual lines of code or specific technologies, but the overall way the system is organised: how its parts are connected, how responsibilities are distributed, and how the project’s evolution, resilience and clarity are ensured.
This article examines the use of both established and emerging architecture types in work with AI agents.
For development involving AI agents, what emerges is not so much entirely new “classical architectures” as architectural styles and practices that make a project understandable, changeable and safe for an agent.
The core idea: an AI agent needs an architecture with explicit boundaries, small modules, good contracts and fast tests.
| Architectural approach | How agent-friendly it is | Why it works well | Risks / drawbacks |
|---|---|---|---|
| Modular monolith | Very high | The whole system lives in one repository but is split into clear modules. It is easier for an agent to see the connections and change code without distributed complexity | Module boundaries must be policed strictly |
| Clean Architecture | High | Clear layers: domain, use cases, infrastructure, API. It is easier for an agent to work out where to add business logic | Can involve a lot of boilerplate |
| Hexagonal Architecture / Ports & Adapters | Very high | External systems are separated behind interfaces. An agent can change an adapter without breaking the domain | Can be overkill for small projects |
| DDD with Bounded Contexts | High | Helps split complex business logic into clear areas | Requires good naming and documentation |
| Vertical Slice Architecture | Very high | Code is grouped by feature: CreateOrder, CancelOrder, PayInvoice. It is easier for an agent to change a single feature locally | Can lead to duplication between features |
| Microservices | Medium | Each service can be changed independently | It is harder for an agent to account for the network, contracts, deployment and API versions |
| Event-Driven Architecture | Medium / low | Separates parts of the system well | It is harder for an agent to trace the consequences of events and asynchronous chains |
| Layered Architecture | Medium | A simple and familiar structure | Business logic is often smeared across services, and an agent may pick the wrong place to make a change |
| Serverless | Medium | Small functions are convenient for local changes | Plenty of hidden platform logic; harder to test end-to-end |
| Plugin Architecture | High | An agent can add new plugins without changing the core | The plugin API needs to be designed well |
Three of the most convenient options.
This is probably the most practical option.
app/
modules/
orders/
domain/
application/
infrastructure/
api/
payments/
domain/
application/
infrastructure/
api/
users/
domain/
application/
infrastructure/
api/
Why this works well for AI:
Task: "add order cancellation" The agent understands: - go to modules/orders - look for business rules in domain - write the cancellation scenario in application - add the endpoint in api - put the database work in infrastructure
This reduces the chance that the agent will start changing everything in sight.
In other words, business logic does not depend directly on the database, API, queues or LLM. It communicates with them through interfaces — ports and adapters.
Example:
OrderService ├─ uses PaymentPort ├─ uses NotificationPort └─ does not know whether it is Stripe, PayPal or a mock
This matters for an AI agent, because it can:
In short: a modular monolith gives the agent clear boundaries, while Clean/Hexagonal gives it safe points of change.

Very convenient for feature-driven development with agents.
features/
orders/
create-order/
command.ts
handler.ts
validator.ts
tests.ts
cancel-order/
command.ts
handler.ts
validator.ts
tests.ts
payments/
pay-invoice/
command.ts
handler.ts
tests.ts
The key characteristic: code is organised by user scenario, not only by technical layer.
This suits prompts such as:
Add a "cancel order" feature
It is easier for the agent to create a new feature folder and leave everything else alone.
Drawback: the shared business model still has to be maintained carefully, otherwise rules will be duplicated.
The core idea:
one business capability = one vertical slice of code.
This helps agents to:
In short: Vertical Slice Architecture makes the codebase look like a set of clear tasks rather than a maze of layers.

A good fit when an AI agent has to add new capabilities frequently.
core/ plugin-api.ts plugin-loader.ts plugins/ export-to-pdf/ telegram-notifications/ stripe-payments/ ai-summary/
Why it is convenient:
New capability = new plugin Less risk of breaking the system core
This is especially useful for IDEs, CMSs, internal platforms, automation systems and SaaS products with extensions.
In the context of AI agents it is particularly convenient: the agent does not have to rewrite the whole system and can instead plug in a new function as a separate module.
| Principle | Why it helps |
|---|---|
| Small files | Easier for an agent to read and change the code |
| Explicit module boundaries | Fewer accidental changes in the wrong place |
| Good naming | The agent understands the meaning of the code better |
| Contracts and interfaces | Less risk of breaking integrations |
| Tests next to the feature | The agent can verify a change faster |
| ADR documents | The agent understands the architectural decisions |
| READMEs inside modules | Explain how the module is structured |
| API schemas / OpenAPI / GraphQL schema | The agent sees the exact contracts |
| Static typing | TypeScript, Kotlin, C#, Go and Rust help catch errors |
| Linters and formatters | The agent writes more consistent code |
The core idea: the core sets the rules, the plugins add behaviour.
This is useful for AI agents because:
In short: Plugin / Extension Architecture gives the agent safe “extension points” where new capabilities can be added without breaking the main system.

| Approach | Why it is inconvenient |
|---|---|
| A large unstructured monolith | The agent cannot tell where the real business logic lives |
| God Service / God Object | Too much responsibility in one place |
| Hidden framework magic | The agent may not understand how the code is actually invoked |
| Tight coupling between modules | A small change breaks many places |
| Many implicit side effects | Hard for the agent to predict the consequences |
| Weak tests or none at all | The agent cannot verify changes safely |
| Too many microservices from the start | A great deal of network and infrastructure complexity |
For most projects that will be actively developed with AI agents, I would choose:
Modular monolith + Vertical Slice for features + Hexagonal/Clean inside complex modules + DDD for complex business logic + strict typing + tests next to the code
Example:
src/
modules/
orders/
domain/
order.entity.ts
order-status.ts
order-policy.ts
features/
create-order/
create-order.command.ts
create-order.handler.ts
create-order.test.ts
cancel-order/
cancel-order.command.ts
cancel-order.handler.ts
cancel-order.test.ts
ports/
order-repository.ts
payment-gateway.ts
adapters/
postgres-order-repository.ts
stripe-payment-gateway.ts
api/
order.controller.ts
This style suits both humans and AI agents: it is clear where the business logic is, where the scenarios are, where the integrations are, and what can be changed safely.
That is, an architecture deliberately optimised not only for people but also for AI agents that read code, plan changes, run tests, refactor and open pull requests.
Important: this is not yet a canonical architecture with a single agreed name, but an emerging style. Recent material from OpenAI and Martin Fowler, along with articles from 2025–2026, speaks more about the shift towards AI-native engineering, agentic workflows and the need for an architecture in which humans focus more on design and oversight while the agent handles implementation.

Conventional architecture was optimised for:
| Previously | Now added |
|---|---|
| convenience for the human developer | convenience for the AI agent |
| scaling the system | scaling changes to the code |
| performance/runtime | agent navigability |
| deployment independence | task locality |
| clean code | machine-readable context |
| documentation for people | executable/context documentation for agents |
The core idea:
A good architecture for an AI agent is one in which a task can be completed locally, against an explicit contract, with a fast test and minimal risk of breaking neighbouring parts.
Agent-Friendly Architecture is a way of designing a product, codebase or system so that AI agents can work with it comfortably.
The idea is simple: the agent should be able to understand, change, verify and safely complete a task.
In practice this usually means:
Provisionally, it could be called:
Agent-Oriented Modular Architecture
Or, more briefly:
AOMA — Agent-Oriented Modular Architecture
This is not an official standard, but it is a good working name.
Its essence:
The system is divided not merely into modules, but into agent-friendly workspaces:
Example structure:
src/
modules/
orders/
AGENT.md
README.md
module.contract.yaml
domain/
order.ts
order-policy.ts
features/
create-order/
task.md
create-order.handler.ts
create-order.test.ts
cancel-order/
task.md
cancel-order.handler.ts
cancel-order.test.ts
ports/
order-repository.ts
payment-gateway.ts
adapters/
postgres-order-repository.ts
stripe-payment-gateway.ts
architecture.rules.ts
Not simply “clean layers”, but a codebase as a navigable environment for the agent.
That is, the architecture answers not only the question:
How should the system work?
but also the question:
How can an AI agent safely change this system?
| Principle | What it means |
|---|---|
| Task locality | A single task should touch as few files as possible |
| Context capsules | Every module has its own short context: README, AGENT.md, contracts |
| Executable contracts | Contracts are verified by tests, schemas, types and linters |
| Vertical slices | Code is grouped around features, not only around technical layers |
| Typed boundaries | Module boundaries are expressed through types and interfaces |
| Fast feedback | The agent can quickly run a local test for a specific feature |
| No hidden magic | Minimal implicit framework behaviour |
| Change maps | The documentation says where to go for typical changes |
| Architecture tests | Automated tests verify that modules do not violate boundaries |
| Clean Architecture | Agent-Oriented Architecture |
|---|---|
| protects business logic from frameworks | protects the codebase from chaotic changes by the agent |
| built around layers | built around tasks, modules and context |
| good for people | good for people + AI |
| the main principle is the dependency rule | the main principle is locality of change and clear context |
| documentation is desirable | documentation for the agent is mandatory |
Microservices give you independent deployment, but they are not always convenient for an AI agent: it is harder for the agent to account for the network, API versions, distributed transactions, observability and asynchronous effects.
By 2026 there are already discussions and even benchmarks comparing which architectures agents find easier to work in. Material on ModulithBench, for example, argues that a modular monolith may be more convenient for agent reasoning than microservices, thanks to locality and lower distributed complexity. This is not a settled scientific consensus, but the direction is telling.
For a real project I would choose the following formula:
Agent-Oriented Modular Architecture = Modular Monolith + Vertical Slice Architecture + Hexagonal boundaries + DDD for complex domains + AGENT.md in every module + architecture tests + typed contracts + local tests for every feature
# Orders Module — Agent Guide Purpose: This module manages order lifecycle. Allowed changes: - Add new order features inside features/ - Put business rules in domain/ - Use ports/ for external dependencies Do not: - Call payment provider directly from domain/ - Import infrastructure from domain/ - Modify payments module without updating contract tests Common tasks: - New order action → create folder in features/ - New persistence logic → update adapter + repository port - New business rule → update order-policy.ts and tests
This is extremely useful: the agent does not merely “guess” where to write code, it receives local instructions.
There is as yet no completely new, officially recognised architecture. But a new style really is taking shape:
Agent-Friendly / AI-Native / Agent-Oriented Architecture
Its defining characteristic:
design the codebase so that an AI agent can safely understand, change, test and extend it in small, controlled steps.
In practice, the best foundation for this right now is a modular monolith + vertical slices + typed contracts + local documentation for agents.
Comments