Maybe giving an AI agent access to a CI pipeline seems fairly reasonable to you. You might be inclined to give it the right tools, some context about the repository and enough permissions to get things done, and before long, it can investigate failed builds, modify tests, review pull requests and recommend whether a build is ready to go out. You want to spend less time attending to routine engineering tasks and have the agent take care of much of that work for you. And because the first few runs often go reasonably well, there is a temptation to give the agent a little more responsibility.
But somewhere in that process, teams start confusing an agent’s ability to perform a task with its ability to decide when that task should be performed. An agent might be perfectly capable of rerunning a failed test, for instance, without being particularly good at establishing whether that failure warrants another run. Give it enough control over the pipeline and it might keep rerunning a genuinely unstable test until it passes, leaving the engineering team with a green build and very little understanding of what actually happened.
The problem is that most of the work involved in giving an agent autonomy happens upfront, while much of what we need to know to justify that autonomy only becomes apparent after the agent has been operating for some time.
In a recent conversation with Mudit Singh, Co-Founder and Head of Growth at TestMu AI, an AI-native software testing platform formerly known as LambdaTest, we discussed how engineering teams are deciding which parts of their development workflows they can confidently hand over to agents.
Mudit sees organizations struggling when they try to automate several dependent engineering processes at once, particularly when those processes have yet to become dependable on their own. His advice is to first understand what a good development workflow looks like, establish how its output should be reviewed and gradually introduce agents into the individual stages.
I think there is an interesting engineering implication here because the permissions we give an agent rarely reflect what we actually know about its performance.
Consider an agent responsible for investigating failed tests in CI. Initially, it only needs permission to read execution logs, inspect traces and recommend what an engineer should do next. The team can observe those recommendations against known failures and establish whether the agent can reliably distinguish an application regression from an infrastructure failure.
And once there is enough evidence that it can do so, the team might give it permission to independently rerun tests affected by an infrastructure failure. That is a fairly bounded decision with a manageable consequence, provided the original failure remains recorded and the number of retries is controlled.
But the same evidence tells us very little about whether the agent should be allowed to modify a failing assertion, quarantine a test or approve a deployment. Each of those actions introduces a different kind of risk and requires its own evaluation.
So instead of assigning an agent some general level of autonomy, I would evaluate its readiness for individual actions. An agent can be autonomous in one part of a workflow and require human approval in another, even when both tasks concern the same build.
The easiest way to introduce this separation is to have the agent propose an action and leave the authorization decision to something that operates independently of the model.
We can implement a simplified version of this in Python. Suppose we have a CI agent with three available actions. It can read logs, request a test retry or request a deployment. Reading logs is permitted within its assigned scope, retrying tests requires evidence of dependable decision-making, and deployment always requires human approval.
First, we need a representation of what we know about the agent’s performance.
from dataclasses import dataclass@dataclass(frozen=True)class Evidence: policy_version: str outcomes: tuple[bool, ...] critical_violation: bool = False
Each outcome represents the result of an independently evaluated decision about whether a test should have been retried. A correct recommendation receives True, including instances where the agent correctly recommends against a retry. The evaluator could use previously classified failures, deterministic infrastructure signals or decisions reviewed by an engineer.
The important part is that this evidence comes from outside the agent. An agent reporting that it made twenty correct decisions is considerably less useful than an independent evaluation establishing that it did.
We can then use that evidence in a small authorization function.
def authorize(action, evidence, scope_ok): known = {"read_logs", "retry_test", "deploy"} if action not in known or not scope_ok: return "DENY" if action == "read_logs": return "ALLOW" if evidence.critical_violation: return "DENY" if action == "deploy": return "HUMAN_REVIEW" if evidence.policy_version != "v1": return "HUMAN_REVIEW" recent = evidence.outcomes[-20:] if len(recent) < 20 or not all(recent): return "HUMAN_REVIEW" return "ALLOW"
For this example, I have set the threshold at twenty consecutive correct decisions. It is deliberately simple and should not be mistaken for a statistically sufficient measure of an agent’s reliability.
The more interesting part is what happens when we evaluate different requests against the policy.
clean = Evidence("v1", (True,) * 20)insufficient = Evidence("v1", (True,) * 19)regressed = Evidence( "v1", (True,) * 19 + (False,))critical = Evidence("v1", (True,) * 20, True)old_policy = Evidence("v0", (True,) * 20)
Using these simulated evaluation records, we can exercise the authorization function under several different conditions.
Scenario and Policy Decision
These scenarios demonstrate the behavior of the policy function using simulated evaluation records, rather than measuring an actual agent’s reliability.
And although this is a small implementation, it establishes a useful property. An improvement in the agent’s ability to make retry decisions does not inadvertently give it authority over deployment. The permissions remain specific to the decisions the agent has demonstrated an ability to make.
In an actual CI environment, the scope check would also need to account for the repository, the particular test, the failure classification and the remaining retry budget. And those checks need to happen in a trusted service before the requested action executes. If the agent already holds credentials that allow it to bypass that service, much of the policy becomes redundant.
One of the common approaches to building agentic development workflows is to introduce another agent whenever the output of an existing one needs to be reviewed. And there is considerable merit in separating those responsibilities.
“You cannot have the same agent write, test and deploy,” Mudit explains. He recommends building a collection of agents that independently handle different parts of the development process, allowing them to act as checks on one another.
But introducing a second agent does not necessarily give us a second source of truth.
Consider a coding agent that incorrectly implements a business requirement and a reviewing agent that only has access to the resulting code and the tests written alongside it. The reviewer might find the implementation technically sound and approve it because the information it needs to identify the original mistake was never provided.
Even using two different models does not resolve that particular problem.
So the reviewing agent needs access to the original requirements, and the verification process needs evidence that neither agent can arbitrarily change. That might come from a human-approved acceptance criterion, a contract test maintained independently of the implementation or an established performance benchmark.
The same principle applies to our CI agent. If another model evaluates its retry recommendations without access to independently established failure classifications, we could end up granting the agent more autonomy based on a series of mutually agreeable but incorrect decisions.
And this is where deterministic checks become particularly useful. A test runner reporting that its browser process terminated unexpectedly gives us something more concrete to work with than an agent’s interpretation of a failed assertion. The two failures should lead to different decisions, and we can encode much of that distinction into the verification infrastructure itself.
As more agents become involved in a development workflow, understanding why a particular decision was made becomes a fairly substantial engineering problem.
Suppose our CI agent reruns a failed checkout test and the subsequent execution passes. By the time an engineer investigates a related production incident, the dashboard might only show the successful result.
Without the original failure, the retry decision and the evidence used to authorize it, there is very little left for the engineer to investigate.
Mudit makes a similar point when discussing AI maturity within engineering teams. In his view, the number of automated processes matters considerably less if the organization cannot trace a failure back to the stage where it originated.
For our policy implementation, a decision record could look something like this.
{ "agent": "ci-triage-agent", "build": "build-1842", "test": "checkout-payment", "action": "retry_test", "failure_type": "browser_process_crash", "policy_version": "v1", "evaluation_ref": "retry-eval-042", "authorization": "ALLOW", "original_result": "FAILED"}
This gives the engineering team a record of what the agent requested, the conditions under which it was permitted to proceed and the original result before the action took place.
I would also associate the evaluation record with the model version, prompt configuration and tools available to the agent at the time of evaluation. Change any of those substantially and we have good reason to reconsider whether the earlier evidence still applies.
And the evidence needs to live somewhere the agent cannot independently modify it. Otherwise, we are effectively allowing the agent to maintain the very record that determines how much authority it receives.
One of the things I find particularly useful about evaluating autonomy at the action level is that we can withdraw it without necessarily taking the entire agent out of the workflow.
Our CI agent might have been making dependable retry decisions for several weeks before an infrastructure change alters the way failures are reported. Suddenly, the classification it has been relying on becomes less useful, and the agent starts recommending retries for failures that warrant investigation.
Under the policy we implemented earlier, a single independently evaluated incorrect decision is enough to put subsequent retry requests back under human review. The agent can continue reading logs and investigating failures while engineers establish what changed.
In practice, I would use different thresholds for different actions and evaluate performance over representative failure conditions rather than rely solely on a rolling count of successful decisions. An agent that correctly handles hundreds of straightforward infrastructure failures might still perform poorly on the occasional payment regression, which could be the failure the organization can least afford to overlook.
Teams also need a way to invalidate previous evaluations when they change the model, its tools or the environment it operates in. Permission changes should take effect at the service executing the action, including revoking credentials or stopping queued work where necessary. Restricting future requests will do little about an operation that has already begun.
So there is little reason to decide how autonomous an agent should be across an entire engineering workflow from day one. Start with a decision engineers already understand well enough to evaluate, have the agent make recommendations without acting on them and collect evidence about the conditions under which those recommendations are dependable.
And when the team eventually gives that agent permission to act independently, it should already know what would cause that permission to be taken away.
Mudit Singh, Co-Founder and Head of Growth, TestMu AI (linkedin.com/in/muditsingh5000/)
Premature Agent Autonomy Is an Engineering Risk was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.