AWS Builder Center
The twin as the control plane: governing AI agents through graphs and transactions - Part 2

The twin as the control plane: governing AI agents through graphs and transactions - Part 2

How Corezoid uses a digital twin, accounts, and transaction history to govern AI-agent spending, concurrency, model selection, limits, and human-approved policy changes.

Series: Inside the Digital Twin (2 articles)

  1. 2
    The twin as the control plane: governing AI agents through graphs and transactions - Part 2 This article

In Part 1, a digital twin told Corezoid’s AI agents where each ticket belongs. This part is about what happens next, when agents work around the clock on a whole company’s backlog: who decides how much they may spend, how many may run at once, which model they use, and how those decisions get better over time.
Corezoid made one choice early and built everything else on it. The values that govern the agents live in the twin as data that people can read and change: limits, prices, the model for each kind of work, and overrides for a project, a repository or a single ticket. Corezoid processes read those values and enforce them. The code decides how a rule is checked; the twin decides what the rule is right now, and keeps the history of every change.
“We are building an autonomous, self-learning system,” Dmitry Makarichev wrote in the project log in the first week. In practice that means three different things, and the twin keeps them apart. Facts accumulate on their own: every run posts its cost and its outcome. Proposals come from the system: from that history it suggests new limits, a better model for a repository, the first draft of a new project’s profile. Decisions stay with people, and each one is recorded as a transaction.
The design fits in four lines. The graph defines where a decision applies. Accounts hold the state and the limits. Transactions record what changed, who changed it and why. Corezoid processes read that context and act on it.

Decision 1: limits are accounts, and a change is a transaction

 Simulator.Company  describes anything that has entities, links and numbers. Every actor in it can carry accounts in any unit, and every change to an account is a transaction with a reference, an author and a comment. That is exactly what an agent platform’s control plane needs.
So there is one policy actor for the whole shift. Its plan accounts hold the monthly budget, runs per day, parallel runs and a tree of spend limits. Model profiles, repository profiles and Jira project profiles are actors too, and any of them can hold its own plan account that overrides the default. The processes that dispatch, start and run the work read those values at every step instead of keeping numbers of their own.
The rule that came with it: a limit changes only by a transaction. Raising runs per day is a +10 with a reason, not an edited field. Weeks later, when someone asks why a limit is what it is, the answer is in the history. “The main thing is that everything is in the twin and under control,” Makarichev says.
The decision paid for itself in an unexpected way. Because limits are accounts, they can be measured like anything else. On 4 November Makarichev noticed that a wave of security patches had been pushed to the next day by the shift’s own cap. “We set these limits ourselves, and they are in our way,” he wrote.
Checking which limits had actually blocked work over two weeks took minutes, because every refusal had been posted. Only two had; the money limits had never been more than 13% used. Four transactions raised the two that mattered. Nothing was deployed.
When limits are data with a history, you can ask the system which of them are protecting you and which are only slowing you down.

What it looks like in the twin

The twin is a graph. Every box an engineer would draw on a whiteboard for this system is a node in it, and every node is an actor with its own fields, accounts and history. The AI Shift twin as a graph: the policy, a Jira project, its repositories, tickets, runs and model profiles:

Figure 1. A slice of the twin in Simulator.Company: one policy, one Jira project, two repositories, two tickets, three runs and two model profiles. Solid lines are ownership; dashed lines show which model each run used. Every run posts its cost and outcome to every node on its path. Illustrative example with English names and made-up values; the structure is the one AI Shift runs on.

The policy at the top is an ordinary actor. Its plan accounts are the limits, and its fact accounts count outcomes by class. In the interface a limit and its usage sit side by side: for parallel runs, the plan is the number of slots, the fact is how many are in use, and the margin is what may still start. Policy accounts in Simulator.Company: plan, fact and margin for parallel runs, refusals and spend:

Figure 2. The policy’s accounts in the same illustrative example. “Refused: no free slot” counts every start that had to be turned down; it is the evidence behind the change in Figure 3.

The list of limits can grow without a release, as long as it is a kind of limit the processes already understand: a count over a window, a number of slots, spend at one level of the tree. Any project, repository or ticket can override a value by holding an account with the same name, and the most specific one wins. A new kind of check still needs code. Day to day, though, steering the system means changing data, from the twin’s interface, a Corezoid process, the API or MCP, and every path ends in the same kind of transaction:
{
  "actor": "AI Shift · Policy",
  "account": "Parallel runs",
  "accountType": "plan",
  "amount": 5,
  "balanceAfter": 15,
  "ref": "limit-parallel-15-security-lane",
  "comment": "Security lane next to the general queue",
  "data": \{
    "previous": 10,
    "new": 15,
    "author": "CTO",
    "via": "Claude Code + Simulator MCP",
    "evidence": "7 refusals: no free slot. Spend under 15% of limits"
  }
}
The reference makes the change idempotent, and the comment and data keep the reason next to the number.

Decision 2: one owner for concurrency

On the first day of the company-wide launch, 47 tickets were released at once against a limit of five parallel runs, and 18 started. Every start request had read the accounts at the same moment, seen free slots and gone ahead.
AWS perspective: Amazon DynamoDB can be a good fit here. It supports conditional updates, which can change a counter only when a condition succeeds.  TransactWriteItems  can combine a counter update with a separate reservation record as one atomic operation. A client request token makes identical transaction calls idempotent for ten minutes. Applications still need durable reservation ownership and expiration logic. DynamoDB Time to Live can remove expired records, but deletion can take several days. Application logic must reclaim expired reservations without waiting for TTL deletion. Sources:  UpdateItem ,  TransactWriteItems , and  DynamoDB TTL .
The fix was structural. The dispatcher now only queues work. One Corezoid process, the starter, reads the accounts every five minutes, takes a slot by posting to the account and only then starts the run. The runs that had started over the limit were cancelled and reversed in the books, so the twin showed what had really happened. A slot comes back when the run reports, and a health check reports for runs that died without doing so, so slots don’t leak.
Concurrency needs one owner. Many processes checking the same limit will all see it free.

Decision 3: every run posts to everything it touched

When a run ends, its cost and its outcome are posted to everything it touched: the ticket, the repository, the Jira project and the model. Every posting carries a reference, so nothing is counted twice. These are four views of the same money, never added up across levels; the only sum that has to balance is the models against the budget.
This is where the twin stops being a dashboard and becomes part of how the system thinks. Every node knows its own history: how many runs went into a repository, what was merged, what was thrown away, and what it all cost. Everything spent on a repository with one model, divided by the merge requests merged there, gives an all-in cost per accepted change, failed attempts included.
The same postings carry outcomes. Part 1 described the twin as a classifier: every decision about a ticket is a class, and every class is an account. A merge request closed because “a developer did it”, “the agent did the wrong thing” or “the change wasn’t needed” lands on a different account at every level, and the next decision reads those accounts. A small example: when the agent reports that it made no changes in a repository, the outcome is posted on the ticket, and the next run of that task skips the repository. Most of what the system learns works this way.


Decision 4: the agent doesn’t price its own work

Claude Code reports a cost at the end of each session, and for models on Amazon Bedrock that estimate was more than four times too high in one test. So the runner ignores it, takes the token counts per model and prices them with the prices stored on each model’s profile in the twin. A price change is a transaction like any other.
Then the books are reconciled: the model accounts must add up to the movement on the budget, and they have matched to the cent since the first gap in the check was fixed. That proves the books agree with themselves; checking the prices against the AWS bill is a separate step. A model with no known price is marked as a lower bound. Unknown is not free. The same holds for every report the system writes about itself: a source that couldn’t be read is “no data”, never zero.
The accounting also failed silently, four times, and every time it made the numbers look better than they were: a currency with zero decimal places showed cheap runs as free; a paged lookup stopped at the first page and lost postings; accounts created without access rules couldn’t be written; a test pipeline released a slot it never took. Each became a check in the regular review.
AWS perspective: AWS recently introduced a concept of spend limit. A spend limit does not validate your internal ledger, but it can contain the impact when accounting misses usage. For eligible projects, AWS Settings  Spend Limits  provide threshold notifications, optional early controls, and project pausing at the monthly limit. Supports resources from these five services: EC2, RDS, Lambda, Bedrock, and SageMaker. Use them for experimentation and sandbox workloads, or where a brief production pause is acceptable. This opt-in control might prevent you from incurring costs if you have a runaway Lambda or unexpected Bedrock spike.
Treat silent failures in your own accounting as the most dangerous kind. They don’t break anything; they just make you wrong with confidence.

Decision 5: optimise for useful work, not for saved tokens

Two weeks into the launch, a forecast showed the month’s budget running out before the month did. The first instinct was to let it run out. Makarichev reversed it the same day: “Our coding agent must not sit idle.” Two thousand tickets were waiting, and the shift’s answers and merge requests were being accepted. An empty slot saved a few dollars and cost a day of work. The budget was raised until the only real constraint was the number of slots, and spend stayed a small fraction of it. A busy agent can waste money too, so that decision only works with the next one.

Decision 6: a safety net set by history, not by guesswork

The team had already fixed several runaway loops one by one, and wanted a guard that doesn’t depend on predicting the next bug. So they added a tree of spend limits as plan accounts: for the whole system, per project and per ticket, plus a cap on runs per ticket. A project or ticket can override its own level, but every level is checked on every start, so a local override never lifts the system’s ceiling.
The values weren’t guessed. They were set just above the peaks of the previous 30 days, and the whole history was replayed against them before switching on: not one past run would have been stopped. The tree is an admission check. A run already going is allowed to finish, so spend can pass a limit by what the runs in flight cost, but no new run starts after that, and an alert fires at 80%.
Here is what a stop looks like. A task spanning several repositories kept relaunching the agent in one where a developer had already merged the fix. Each run answered “no changes needed”. After 20 runs and about two dollars, the per-ticket limit stopped it and the ticket said why. The rule from Decision 3, that a repository with no changes is closed for the task, came out of that stop.
Some waste is cheaper to prevent than to cap. Twice in one day an agent finished its work and then couldn’t hand it in: once the push was refused, and once merge requests were switched off in the repository. Now the delivery path is checked before the agent starts, and if it is closed, nothing is spent and the ticket says why.
Calibration stays a loop. The system replays the last 30 days against the current limits and proposes new values; a person approves them. The same pattern starts every new part of the twin. When a project joins the shift, the AI drafts its profile from the history of how that project has actually been run, and the project’s lead approves it. The system never changes its own limits.

Learn the guardrails from your own history, replay before you switch them on, and let the system propose but not approve.

Decision 7: models are profiles, and every switch is a lesson

Models are actors in the twin, not constants in a pipeline. Each alias has a main model, a fallback and prices. The choice for a run is layered: a label on the ticket wins, then the repository’s default, then the project’s, then the classifier. Complex work and the engine core go to Claude Opus, ordinary changes and answers to Claude Sonnet, small internal calls to Claude Haiku. Every run says in the ticket which model it used and how to change it.
The layering came from people. Two days in, the Simulator.Company team said the default model was too weak for their work. Instead of a new rule in code, their repositories got a default on their profiles. A developer can also redo any task on another model with one command, and every switch is posted to an account. Over time those switches show which model each part of the code actually needs. Fallbacks live on the same profiles and post to the same accounts, so they stay under the same limits.
AWS Recommendation: Amazon Bedrock provides  flexible mechanisms  to track the cost. If you need billed costs by user or team, use IAM principal attribution. If you need billed costs by application or workload, use application inference profiles for bedrock-runtime, or Projects and Workspaces for bedrock-mantle. For per-prompt token usage and calculated cost, use request metadata with model invocation logs. To get both invoice-accurate totals and per-prompt details, combine one of the billing attribution methods with request metadata.

Working with the twin through MCP

People change the twin the same way the processes do. Simulator.Company has an MCP server, so a person can ask a question or make a change from Claude Code. A typical session, shortened; the calls are simplified pseudocode:
> Which limits actually refused work in the last two weeks?

getAccounts(Policy, plan)
getAccounts(Policy, "refused", last 14 days)

> Raise parallel runs by five. Reason: a security lane next to the general queue.

createTransaction(
    Policy, "Parallel runs", plan, +5,
    ref: "limit-parallel-15-security-lane",
    comment: "Security lane next to the general queue")

> Give the engine core project its own daily spend limit, half the default.

createTransaction(
    "Jira project profile · engine core",
    "Spend, one project, 24 h", plan, +125,
    ref: "limit-project-spend-engine-core",
    comment: "Own limit for the engine core")

The change goes through the same API the processes use, lands in the account’s history with an author and a reason, and takes effect on the starter’s next pass. The second request shows the override at work: the project gets its own limit by holding an account with the same name, and the rest of the company keeps the default. Transaction history of the Parallel runs limit: the initial 10 slots and the +5 change, each with a reference and a reason:

Figure 3. The history of one limit, recorded in the illustrative example a minute apart. In the real twin the lines can be weeks apart, and “why is it 15?” is answered by the newer one: who changed it, how, and on what evidence.

The full loop

Put together, the story from Decision 1 runs through the whole design. A limit blocked useful work. The graph showed where it sat. The refusals posted on its account were the evidence. A person decided, and the decision became a transaction with its reason. The processes applied the new value on their next pass, and the next refusal, or its absence, landed on the same account.

What the twin learned

Loop
Signal
What changes
Limits
Refusals posted on accounts
Limits that only slowed work are raised by a transaction
Spend tree
30-day replay of all runs
New values proposed, approved by a person
Models
People switching a task to another model
Defaults per repository and project
Outcomes
Why each merge request was merged or closed
The next decision for that ticket, repository and model
Accounting
Regular reconciliation and checks
Silent failures become alerts
New projects
How the project has actually been run
A first draft of its profile, approved by the project lead
Delivery
Work that was done but couldn’t be handed in
A check before the agent starts

What other teams can apply

Corezoid's experience suggests six lessons:
  1. Put limits, prices and models in the same place as the work. If the platform can’t record who changed a limit and why, you’ll be guessing at the worst possible moment.
  1. Post every run to everything it touched. Cost and outcome on the ticket, repository, project and model turn a log into memory the system can use.
  1. Give concurrency one owner. A single starter or an atomic, idempotent reservation beats many processes reading the same counter.
  1. Optimise for useful work, and contain runaways with limits learned from history. Replay before switching on.
  1. Let the system propose and people approve. Self-learning doesn’t mean self-authorising.
  1. Control Plane Is a Key. A control plane you can read, change and learn from is not an extra layer on top of an agent platform. It is the platform.
Next in the series: an AI agent on production servers without a single key. Part 3 shows how the same twin lets agents diagnose and patch servers in customers’ data centres and AWS accounts through a gate that holds every credential, records every command and lets a person approve every change.


Any opinions in this article are those of the individual authors and may not reflect the official opinions of AWS.

Series: Inside the Digital Twin (2 articles)

  1. 2
    The twin as the control plane: governing AI agents through graphs and transactions - Part 2 This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article