Blog Post

Azure Architecture Blog
17 MIN READ

Swap the agent, keep the decision

dylandejong's avatar
dylandejong
Icon for Microsoft rankMicrosoft
Nov 30, 2026

Five architectural invariants for embedding replaceable AI agents in governed business processes.

Imagine an AI agent that handles customer credit requests. Over a year, the business tunes its approval rules, raises the agent's authority step by step, builds a test set from real cases and records thousands of decisions. Then the model is retired, or a better agent comes along. What has to change: only the agent, or also the rules, the approvals, the tests and the decision history?

For many agents built today, it is the second. They are built into one workflow, one orchestrator or one platform engine. That works for a pilot. But when rules live in prompts, approval is something the agent does and history sits in framework memory, a new agent means rebuilding part of the process. That is a separation problem more than an orchestration problem.

The rules, test cases and human corrections that grow around an agent capture how your organization decides and works. That institutional learning is an asset whose value should not depend on one model, framework or provider (sovereignty). This article proposes five architectural invariants that keep it when the agent changes, a composition I call Contract-Driven Agentic Architecture (CDAA), and one way to build it on Azure.

1. Why embedding an agent is the hard part

Building an agent has become quick. Embedding it in a process that already exists has not. That process has a system of record, approvals, service levels and an audit trail. The agent brings a model, a prompt, tools and a framework, each with its own release cycle. Agents usually end up in one of three places (Figure 1). None is wrong in itself, but each can lead to the same three problems.

Figure 1. Three common ways to embed an agent, each holding part of the business logic.

  1. Business rules move into the agent. A rule such as "credits above a set amount need approval" becomes a sentence in a prompt. Routes become a graph in an agent framework, next to the ERP or CRM that already owns the process. You can version a prompt, but you cannot prove that a model follows it every time.
  2. Agents hold authority. When the agent's identity can write to the system of record, the same component decides and acts. Approval becomes an instruction to the model instead of a control.
  3. History and evaluation are tied to the agent. Models change on someone else's schedule [1]. When traces and test sets are stored per agent, a replacement loses the trail, and the baseline to compare its successor against.

 

So I start from one requirement: every agent or model must be replaceable without losing the business logic, the contract terms, the history and the evaluation. If any of them lives inside the agent, the agent is not replaceable. It can only be rebuilt.

Must survive a replacement

Where it often lives today

Where CDAA keeps it

Business logic

Prompts, agent code, orchestrator graphs

The process, and rules outside every agent

Contract terms

Implicit in prompts and tool definitions

A versioned contract per capability

History

Agent threads and framework logs

An evidence store, keyed by process instance and contract version

Evaluation

Test sets tuned to one agent and one model

One suite per contract, run against any implementation

2. Contract-Driven Agentic Architecture

CDAA rests on one idea: the contract, not the agent, is the unit of design and replacement. A contract describes a business capability, such as "propose a credit for a late delivery": what goes in and out, what may be used and proposed, and how results are judged. Any implementation that meets it can do the work: a vendor agent, an in-house agent, a rules component or a person. The agent decides how to do the task. The business decides what may happen, keeps the process state and carries out the transaction (Figure 2).

Figure 2. Autonomy and authority on two sides of the contract.

Existing patterns, and where they stop

Each established pattern solves part of the problem. Agent as a service, for example through A2A [2], agent as a worker and agent as a tool give a stable interface. Bounded autonomy [3] and human in the loop [4] add limits and accountability. In supervisor and worker, a manager agent delegates, and in evaluator and optimizer, one agent checks another's work [4]. Event-driven agents [5], an agent gateway [6] and durable execution [7] add loose coupling, controlled access and recovery. What they can leave open is where the rules, the authority and the history live when the agent itself changes.

Two recent posts on this blog make related points: Jiri Binko proposes "AI reasons; authorized services act; governed data measures what happened" [8], and Dominik Zemp keeps authority outside the model and lets agents earn autonomy through evaluation [9]. I agree with both. The closest prior work I found is an individual Internet-Draft, the Agent Action Decision Protocol (AADP). It separates per-action authorization from agent identity and specifies approvals, idempotency and decision evidence [10]. Research on agent contracts formalizes resource and time bounds [11] and behavioral contracts enforced at runtime [12].

What is new, and what is not

None of the building blocks is new. CDAA combines them around a different goal: keeping a business capability, and what the organization learned around it, independent of the AI that does the work. The result is a property you can test: add, replace or remove an implementation without changing rules, routes or decision records. Orchestration decides how agents work together. CDAA decides how they take part in a governed business process, so it complements orchestration.

3. Five architectural invariants

Patterns describe what to build. Invariants describe what must stay true while everything around them changes: the model, the framework, the provider, and even whether a program or a person does the work. I use five, each with a test you can run.

01 Replaceability

Any conforming agent, deterministic component or human participant can fulfill the same contract.

A replacement does not need to give the same answers as the agent before it. Two good agents can give different answers that are both right. Instead, it must meet the same contract at four levels. That is behavioral substitutability.

Compatibility

What the replacement must keep

Syntactic

The input and output schemas

Semantic

The meaning of inputs, outputs and proposed actions

Behavioral

The acceptance criteria on the contract's evaluation suite

Operational

The agreed security, latency, availability and cost limits

The idea goes back to the Liskov substitution principle [13], but for agents, Microsoft's orchestration guidance recommends scoring output against criteria rather than exact matches [4]. Replaceability is also your exit plan when a model is retired or a provider no longer fits. Test: bind a second implementation to one contract and run its suite. Nothing in the business architecture should change.

02 Bounded autonomy

Agents independently determine how to fulfill a task within explicitly defined boundaries.

Inside the boundary, the agent plans, chooses tools and reasons freely. The boundary is enforced outside the agent: by its identity, by the gateway in front of its models and tools, and by network rules that make the gateway the only route. A prompt cannot widen it. Test: ask an agent to call a tool outside its contract, then call that tool directly. Both calls should fail, whatever the model decides.

03 Independent authority

Agents cannot grant themselves permissions or bypass business authorization.

No agent holds a write credential to a system of record. A separate policy decision point answers allow, escalate or deny for every consequential action, and a separate executor carries out what is allowed. The rules look at the capability, the action, the level and the facts. They never name an agent. The agent's identity proves who is calling and which contract it is bound to. Nothing the agent supplies counts as a fact. Test: search the rules for implementation names, and try to write with an agent's identity. The search should find nothing, and the write should fail.

04 Evidence by design

Every consequential decision and action produces attributable, correlated evidence.

Each step writes a record with one correlation ID: which implementation proposed what, on which facts or fact versions, under which contract and policy versions, what was decided and what happened. A log tells you what a component did. Evidence tells you why the business let it happen. Learning is what the business changes as a result: a rule, a limit or a test case. Keep personal data to a minimum, and set retention before you make records immutable. Test: rebuild the full chain of one action from last week from the evidence store alone, without replaying the agent's reasoning.

05 Process sovereignty

Business process state, rules and outcomes remain independent of agent implementations and AI providers.

The process keeps its state in its own system of record or durable workflow, or runs as a choreography of typed events. It needs no central agent orchestrator. Known routes stay in deterministic code, not in a model, as Microsoft's guidance advises [4]. Agents exchange typed, versioned messages, and a message is a report, never an instruction, which narrows the inter-agent risk that OWASP lists as ASI07 [14]. Sovereignty then covers how the business decides and learns, not only its infrastructure, data and models. Test: switch an agent off. The process should route its work to the contract's fallback and keep its state.

4. Separate autonomy from authority

Invariants 02 and 03 rest on the most important principle in the design. Autonomy is what an agent may work out and propose. Authority is what it may actually make happen. The two belong to different owners.

Responsibility

Owner

Define business objectives

Business process

Determine how to solve a task

AI agent

Select permitted tools

AI agent, within policy

Propose a business action

AI agent

Authorize a business action

Policy decision point

Execute a business transaction

Executor

Validate the outcome

Independent evaluator or business process

Maintain business process state

Business process runtime

Autonomy without authority

An agent can have significant reasoning autonomy without significant operational authority. That is what most business processes need: let the agent think freely, and let something else decide what happens. Aleksey Lekontsev makes a related argument: coordination and authority are separate design decisions [15].

Two settings in two places

The contract sets the boundary, including the highest level the capability can ever reach (Figure 3). The policy registry sets how much of that the business delegates today: a level of delegated authority, not of autonomy. Raising it does not change how the agent reasons, only which of its proposals run without a person. The three levels below are my own classification, not a standard: AADP defines per-action tiers [10], and Feng and colleagues describe a broader scale [3].

  • At L1 (assist), the implementation informs a person, who decides and acts. It proposes no actions.
  • At L2 (recommend), the implementation proposes an action. A person approves or rejects it, and the executor acts on approval.
  • At L3 (act within limits), the policy decision point allows proposals within approved limits, and the executor acts. The rest goes to a person, unless the rules deny it.

A new implementation can also run in shadow mode, with no authority at all (section 5).

The level is data, not code. Teams often build autonomy levels into the prompt, tools or workflow, so a change needs a release. Here the policy decision point reads the level at decision time, like any other fact. Raising a level is a reviewed change backed by evaluation results. Lowering a level or revoking a binding takes effect at once, even for decisions that have not run yet (section 6). Reversing an action that already ran is a business step, such as canceling the credit. No agent can change its own level.

 

Figure 3. The contract sets the boundary and the highest level; the registry holds the current level of delegated authority.

Allow, escalate or deny

In Rego for Open Policy Agent (OPA), the credit rule can be this short:

package credit.decision
import rego.v1

default decision := "deny"

decision := "deny" if {
    not valid_input
} else := "deny" if {
    input.proposal.amount > input.facts.eligible_amount
} else := "allow" if {
    input.level == 3
    input.facts.open_dispute == false
    is_number(data.limits.issue_credit.max_amount)
    input.proposal.amount <= data.limits.issue_credit.max_amount
} else := "escalate" if {
    input.level >= 2
}

valid_input if {
    input.capability == "customer_credit"
    input.proposal.action == "issue_credit"
    input.level in {1, 2, 3}
    is_number(input.proposal.amount)
    input.proposal.amount > 0
    is_boolean(input.facts.open_dispute)
    is_number(input.facts.eligible_amount)
}

The rule has three answers.

Answer

When

What happens next

Allow

L3, no open dispute, and the amount within both the limit and what the customer is eligible for

The executor acts

Escalate

The proposal is valid, but at L2, above the limit, with an open dispute, or with a missing or mistyped limit

A person decides

Deny

Missing or mistyped input, an amount above what the customer is eligible for, or a proposal at L1

The case goes to the contract's fallback

Before the rule runs, the policy decision point checks who is calling, that the proposal is for the order in the task, and the contract's highest level. Then it adds the current level from the registry and the facts from the systems of record. OPA's own example for agent tool calls judges the request itself: the tool and its parameters [16]. Here, facts never come from the request, so injected text cannot change them.

5. Swap the agent in practice

Take the customer credit capability. A vendor agent is bound to it at L3, and the business wants an in-house agent instead. This is the contract both must meet:

contract: customer_credit
version: 2.1.0
owner: Customer service operations
capability: Propose a goodwill credit for a late delivery
input: CreditRequest v2        # order, customer, reason
output: CreditProposal v2      # action, amount, order, rationale
actions: [issue_credit]
tools: [orders.read, customers.read, credit-policy.read]
never_decide: [account closure, legal claims]
evidence: [process_id, idempotency_key, implementation, model,
           proposal, facts, decision, versions, outcome]
evaluation:
  suite: suites/customer-credit/v2
  accept: {correct_outcome: ">= 95%", rule_breaches: 0, p95_seconds: "<= 20"}
fallback: credit-desk queue
max_level: L3

The swap takes four steps.

  1. Shadow. The in-house agent gets a copy of every live task. Its proposals go only to the evaluator, marked as shadow. Its calls run under their own gateway quota, so they cannot slow the vendor agent, which keeps doing the work.
  2. Judge it against the contract. The evaluator scores the in-house agent on the contract's acceptance criteria, not on agreement with the vendor agent. Where the two disagree, a person reviews the case. The vendor agent can be wrong too.
  3. Cut over. One reviewed registry change makes the in-house agent active at L2 and unbinds the vendor agent. Tasks still in flight go to the new binding with their idempotency keys, so none stalls and none runs twice. A person now approves each credit, so plan reviewer capacity first. More results and a second review raise it to L3.
  4. Keep the history. The vendor agent's decisions stay in the evidence store, keyed by process instance and contract version.

Shadow mode cannot issue a credit. Its identity has read-only scopes, the policy decision point accepts proposals only from the active binding, and the executor writes once per idempotency key.

The new agent's deployment, identity, binding and starting level change. The business architecture stays (Figure 4): rules, boundaries, process state and routes, decision history, acceptance criteria, the executor and, if the new agent conforms, the contract.

Figure 4. Swapping the credit agent: the implementation changes, the business architecture stays.

Hold the boundary, keep the learning

The swap only works if the learning survives it. Keep the test cases, acceptance criteria and evaluator definitions (rubrics, grading prompts and code checks) in Git with the contract, in formats any evaluation tool can read. If a model grades the output, pin that judge model and re-baseline when it changes. Every human override becomes a candidate test case for the next implementation. Agents can propose changes to rules or contracts, but only an owner's review makes them. Agent memory is a replaceable cache, never the only copy of anything the business needs.

6. Example: building CDAA on Azure

CDAA needs no specific product. Here is one way to build it on Azure, following the credit request from event to evidence (Figure 5).

  1. A credit request for a late delivery starts a process instance. It runs on Azure Durable Functions, and the Durable Task Scheduler keeps its state. Durable Task works with any agent framework [7]. An existing workflow or BPM engine can do this too.
  2. The process sends a typed, versioned task on Azure Service Bus. Contracts and rules live in Git, and a release pipeline publishes approved versions to the process runtime and the policy bundle. Bindings and levels live in a registry that the policy decision point and the executor read on every call, so lowering a level needs no release. Azure API Center lists each agent for discovery only [17].
  3. The bound implementation takes the task: an agent in Microsoft Foundry Agent Service [18] or on Azure Container Apps, an Azure Functions component, or a person through a work queue. Model and tool calls go through Azure API Management as AI gateway [6]. Tool calls use each agent's own Microsoft Entra Agent ID [19], with read-only roles.
  4. The implementation returns a typed proposal: contract version, action, amount, order and a short rationale. Only its identity can send to its queue, so the policy decision point knows who is calling.
  5. The policy decision point adds the level and the facts, and Open Policy Agent on Azure Container Apps evaluates the rules.
  6. On allow, or after a person approves, the executor writes to the system of record. It is an Azure Functions app with a managed identity, and the only writer for this capability.
  7. Every step writes a decision record with the same correlation ID to Azure Cosmos DB, and the change feed copies it to immutable Azure Blob Storage [20] for retention. Traces go to Application Insights through OpenTelemetry [21].
  8. The evaluator uses Microsoft Foundry evaluations to score each implementation's outputs, from test runs or traces, against the contract's suite of custom evaluators [22]. It runs before a swap and on sampled production traffic [21], and in shadow mode.
Figure 5. One way to build CDAA on Azure. Networking and landing zone services are not shown.

Bind the decision to the execution

Between allow and act, the world can change: a dispute opens, the eligible amount drops, or someone lowers the agent's level. So the executor never acts on a bare allow, and it reads decisions from a queue that only the policy decision point can send to. Each decision names the exact action, amount and target, the fact versions and authority it relied on, an expiry and an idempotency key. The executor then does four things.

  1. It never writes twice. Service Bus delivers messages at least once, so the executor must be an idempotent consumer: handling a message twice has the same effect as handling it once [23]. The process sets one idempotency key per intended action, and a new decision for that action keeps it. If the key is already in the system of record, the executor records the outcome and stops. The key is not the correlation ID.
  2. It checks that the decision has not expired and that the authority was not lowered or revoked since. If either happened, the case goes back to the process for a new decision.
  3. It checks and writes in one step, with a conditional update on the record's version (such as an ETag) or one database transaction. The key goes into the same write, for example as the credit's external reference. If the record moved, the case goes back for a new decision.
  4. It records the outcome. The business write and the evidence record live in different stores and cannot share a transaction. Where the system of record allows it, the executor writes the outcome to an outbox in the same transaction, and a relay publishes it to the evidence store [24]. Either way, a reconciliation job matches actions to decision records by idempotency key and flags any gap.

Facts held in another system cannot join that write. Keep the expiry short for them, and let reconciliation flag any that changed. A decision that a person approved is checked the same way, with its expiry counted from the approval. Use one executor per capability or trust boundary, not one for the whole enterprise, so one stolen credential cannot write everywhere.

7. Trade-offs

What you gain

What it costs

Replace models, frameworks and providers without touching rules, routes or process state.

More parts to run: a registry, a policy decision point, executors and an evidence store.

Authority changes are reviewed data changes, not releases.

Contracts and schemas need owners, versions and reviews, like APIs.

One evidence trail across agents, programs and people, and every implementation judged on the same criteria.

Each contract needs labeled cases. Evaluation and shadow runs cost model calls and reviewer time.

The process stays in charge, so you can adopt CDAA one capability at a time.

Agents cannot act outside their contract, even when that would help.

No agent can widen its own permissions, and injected text cannot become a fact.

An extra decision call per action. The policy decision point must fail closed, and the executor must handle expiry, retries and reconciliation.

When to use it

Use CDAA when agents act on money, accounts, contracts or people, when they come from several sources, when rules change often, when you want to raise delegated authority step by step, or when you expect to change models or providers. Skip it for a single read-only assistant, a prototype, or open-ended research where the route cannot be known in advance. There an orchestrator fits better, and you can still keep invariants 03 and 04 behind it.

8. Start on Monday

  1. List the actions in your process that change a system of record, and who owns each one.
  2. Write one contract per capability, with the fields in Figure 3, and give it an owner.
  3. Move business rules out of prompts into a policy decision point. Add a CI check that fails when a rule names an implementation.
  4. Remove write credentials from every agent identity, and give them to one executor per capability.
  5. Run every new implementation in shadow mode first, and raise its level only with evaluation results.
  6. Run the replacement test: bind a second implementation to one contract and count what else had to change. The target is nothing in the business architecture.

Models will change faster than your contracts, and contracts faster than your processes. Design so that each can change on its own.

References
  1. Microsoft Learn. Model retirement schedule, Microsoft Foundry. https://learn.microsoft.com/en-us/azure/foundry/openai/concepts/model-retirement-schedule
  2. A2A Project. Agent2Agent (A2A) Protocol Specification, version 1.0.0. https://a2a-protocol.org/latest/specification/
  3. K. J. K. Feng, D. W. McDonald and A. X. Zhang. Levels of Autonomy for AI Agents. arXiv:2506.12469, 2025. https://arxiv.org/abs/2506.12469
  4. Microsoft Learn. AI agent orchestration patterns, Azure Architecture Center. https://learn.microsoft.com/en-us/azure/architecture/ai-ml/guide/ai-agent-design-patterns
  5. Microsoft Learn. Event-driven architecture style, Azure Architecture Center. https://learn.microsoft.com/en-us/azure/architecture/guide/architecture-styles/event-driven
  6. Microsoft Learn. AI gateway capabilities in Azure API Management. https://learn.microsoft.com/en-us/azure/api-management/genai-gateway-capabilities
  7. Microsoft Learn. Durable Task for AI agents. https://learn.microsoft.com/en-us/azure/durable-task/sdks/durable-task-for-ai-agents
  8. J. Binko. The Model Isn't the Boss: An Azure Architecture for Accountable AI Agents. Azure Architecture Blog, 7 November 2026. https://techcommunity.microsoft.com/blog/AzureArchitectureBlog/the-model-isn%E2%80%99t-the-boss-an-azure-architecture-for-accountable-ai-agents/4571335
  9. D. Zemp. Evidence before autonomy: Designing multi-agent battery passports on Azure. Azure Architecture Blog, 23 November 2026. https://techcommunity.microsoft.com/blog/AzureArchitectureBlog/evidence-before-autonomy-designing-multi-agent-battery-passports-on-azure/4575061
  10. S. Saha. The Agent Action Decision Protocol (AADP): Per-Action Authorization for AI Agents. Internet-Draft draft-saha-aadp-04, 27 September 2026, work in progress. https://www.ietf.org/archive/id/draft-saha-aadp-04.html
  11. Q. Ye and J. Tan. Agent Contracts: A Formal Framework for Resource-Bounded Autonomous AI Systems. arXiv:2601.08815, 2026. https://arxiv.org/abs/2601.08815
  12. V. P. Bhardwaj. Agent Behavioral Contracts: Formal Specification and Runtime Enforcement for Reliable Autonomous AI Agents. arXiv:2602.22302, 2026. https://arxiv.org/abs/2602.22302
  13. B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Transactions on Programming Languages and Systems 16(6), 1994, pages 1811 to 1841. https://doi.org/10.1145/197320.197383
  14. OWASP GenAI Security Project. ASI07: Insecure Inter-Agent Communication. OWASP Top 10 for Agentic Applications 2026. https://genai.owasp.org/agentic-applications-2026/asi07-insecure-inter-agent-communication/
  15. A. Lekontsev. Central authority, distributed cognition. 20 October 2026. https://lekontsev.uk/articles/l3-orchestration
  16. Open Policy Agent. Agent tool calling. https://www.openpolicyagent.org/docs/agent-tool-calling
  17. Microsoft Learn. Register and manage agents in Azure API Center. https://learn.microsoft.com/en-us/azure/api-center/register-manage-agents
  18. Microsoft Learn. What is Microsoft Foundry Agent Service? https://learn.microsoft.com/en-us/azure/foundry/agents/overview
  19. Microsoft Learn. What is Microsoft Entra Agent ID? https://learn.microsoft.com/en-us/entra/agent-id/what-is-microsoft-entra-agent-id
  20. Microsoft Learn. Store business-critical blob data with immutable storage in a write once, read many (WORM) state. https://learn.microsoft.com/en-us/azure/storage/blobs/immutable-storage-overview
  21. Microsoft Learn. Observability in generative AI, Microsoft Foundry. https://learn.microsoft.com/en-us/azure/foundry/concepts/observability
  1. Microsoft Learn. Custom evaluators (preview), Microsoft Foundry. https://learn.microsoft.com/en-us/azure/foundry/concepts/evaluation-evaluators/custom-evaluators
  1. Microsoft Learn. Idempotent Consumer pattern, Azure Architecture Center. https://learn.microsoft.com/en-us/azure/architecture/patterns/idempotent-consumer
  2. Microsoft Learn. Implement the Transactional Outbox pattern by using Azure Cosmos DB, Azure Architecture Center. https://learn.microsoft.com/en-us/azure/architecture/databases/guide/transactional-out-box-cosmos
Published Nov 29, 2026
Version 1.0
No CommentsBe the first to comment