
Essay Code and Repo Agents
Agent-Driven Dependency Upgrade Workflow in CI
Narrow triggers, tight permissions, and mechanical gates keep upgrade agents safe.
An agent-driven dependency upgrade workflow in CI earns its autonomy through limits. Dependency upgrades are bounded, repetitive, and testable, which makes them a useful first job for an agent. The workflow works when narrow triggers, restricted permissions, spending limits, mechanical gates, and independent review turn the agent’s output into a controlled proposal.
Why dependency upgrades are the right first job for a CI agent
A dependency manifest and a test suite give an upgrade agent a defined assignment. There is no vague product requirement to interpret. The agent changes a version, repairs the resulting incompatibilities, and runs the build to find out whether the result meets a mechanical success criterion. That gives the pipeline an objective basis for rejecting failed work. Because changes stay on a branch rather than main, an unsuccessful attempt has a small blast radius and can be reverted with a single command.
The repetition makes this bounded task worth delegating. Elastic’s Cloud Control Plane team had Renovate generating PRs across 500 actively updated dependencies. At that volume, reviewing failures one by one becomes unsustainable. An agent can take on the repeated work of interpreting build failures and repairing upgrade-related code without being granted authority over unrelated product decisions.
How the three tool tiers divide the upgrade work
The useful architecture layers three kinds of tools. Tier 1 consists of rule-based bots such as Dependabot and Renovate, which propose patch and minor version bumps and handle security alerts around declared dependencies. Alongside an agent, they provide the routine upgrade machinery, although their focus on declared dependencies leaves a gap around transitive vulnerabilities.
Tier 2 consists of deterministic codemods, including jscodeshift and similar AST transform tools. These handle mechanical API renames and import rewrites at scale, provided a human has authored and maintained the transform for that migration pattern. Predictable edits belong in this layer. Tier 3 adds agents for multi-pattern migrations, breaking API changes, and build failures with no single deterministic fix. The agent interprets what remains, rewrites affected call sites, and produces a reviewable account of the changes.
This division keeps reasoning where reasoning is needed. A known transform can stay out of an open-ended model task, while a build failure that the rules cannot fix needs room for a different repair.
Triggering the upgrade scan correctly
The first operational decision is what wakes the agent. A scheduled sweep on a daily or weekly cadence makes most dependency work predictable and easier to budget. In a workflow automation platform, that means a schedule event with a cron expression. The schedule defines when a scan can begin. It should not become permission to start unlimited upgrade jobs.
Security alerts let the agent take on a narrower set of fixes. A CI-failure hook sends the agent a build failure tied to a dependency between scheduled sweeps. For an event-driven workflow, the automation platform’s event filter should select the relevant dependency work.
Timing also needs a release cooldown. Renovate’s minimumReleaseAge waits a specified amount of time before proposing an update, and the same principle belongs in agent triggers. Broad triggers that act as soon as versions come out can start hundreds of runs at once in a busy monorepo.
Scoping permissions so the agent can't reach production
Once the trigger is narrow, permissions define the agent’s reach. Give it branch-write access only to agent-prefixed branches such as agent/*, the secrets required by the build, and no production credentials or deployment rights. It must not write to protected branches. Its output is a proposal that requires human approval or an independent gate, never its own approval.
These restrictions must exist outside the prompt. An instruction to “only touch dependency files” cannot enforce a boundary, so the post-agent gate must reject out-of-scope changes before they become a review-ready PR. Pipeline configuration, infrastructure-as-code, and the agent’s own permissions belong outside its upgrade remit. Otherwise, the worker could change the controls that constrain it.
Network restrictions add another boundary where supported. The goal is allowlisted egress from the runner, although enforcement depends on the platform and is not available everywhere. The workflow’s risk assessment should state where that network control is missing. A prompt cannot substitute for a missing network control, just as a convincing PR description cannot substitute for restricted credentials.
Capping cost before the agent starts work
Permissions limit what the agent can touch, while spending controls limit how much it can run. Both must be set before execution begins. A per-run token or dollar limit should terminate the job when exhausted, rather than send a warning that nobody sees during unattended operation. The pipeline also needs a concurrency cap set at a level the team is comfortable paying for all at once.
Model routing provides the third control. Route by task ambiguity, because comparable work can cost several times more on a frontier reasoning model than on a cheaper capable model. A lighter model can handle a patch bump that needs only a manifest edit. A major upgrade that needs a model to read build logs and fix several files can call for a more capable one.
Spend alerts alone can miss some ways that jobs waste money. Alert on consecutive failures of the same job as well. An agent that repeatedly fails and retries on schedule can consume budget indefinitely while each attempt remains below its individual limit. This is why a cheap run is not necessarily a cheap workflow.
Elastic’s Cloud Control Plane team had Renovate generating PRs across 500 actively updated dependencies.
Structuring the agent's upgrade pass in three phases
With those boundaries established, separate the upgrade pass into planning, execution, and verification. Planning begins with the dependency’s changelog or official migration guide. Before editing files, pin the target version and save the guide with a structured plan for the breaking changes that affect the codebase. Published semantics should constrain the proposed repair. Otherwise, the agent may guess at what is missing from what it learned in training data.
Execution applies transforms, updates the manifest, and follows an edit-compile-test loop. Elastic provides a concrete example of this division of labor. Renovate opened upgrade PRs, while Claude analyzed failed Gradle build logs and committed repairs to the PR branch. The agent made 22 commits in the first month. That pattern assigns the agent a specific failure to resolve rather than an open-ended request to modernize the repository.
Verification then runs the suite, interprets remaining failures, separates upgrade-induced failures from pre-existing flakiness, and records unresolved work. Long migrations also need durable memory. Store approved decisions, milestones, and extracted changelog facts separately from the active subtask and current tool results. Context compaction can preserve what happened while losing why an earlier decision constrained the next one, so durable checkpoints must retain that reasoning.
Test gates that decide whether the PR opens at all
An independent gate must check the agent’s verification evidence before a human gets a review-ready PR. For workflows that start from an existing bot PR, that distinction remains important because agent commits do not constitute acceptance. A persuasive explanation should never weaken the mechanical checks.
Enforce a defined diff-size budget and expected file paths. Reject unauthorized changes to authentication, CI configuration, or infrastructure, and check separately for new dependencies unless the job permits them. Test files deserve extra scrutiny. An agent trying to make a suite pass may leave the code uncorrected by skipping a test, loosening an assertion, or catching an exception. On gate failure, discard the branch and log the attempt rather than opening a new PR whose purpose is to explain unfinished work.
The agent itself also needs repeated evaluation. Red Hat’s guidance on CI/CD for agentic AI covers testing agents, but its point on nondeterminism also applies when agents do CI work. One upgrade run that succeeds gives no proof that the agent will work reliably. Regular evaluations beyond the PR gate are needed because externally hosted model behavior can change without a pipeline configuration change.
The supply-chain attack surface that automated upgrades open
Passing tests does not make a dependency trustworthy. Automation can amplify a compromised release by moving it quickly into many environments. Endor Labs’ State of Dependency Management report found that the vast majority of open-source vulnerabilities reside in transitive dependencies. Adding an agent above tools focused on declared dependencies does not, by itself, close that structural gap.
The LiteLLM compromise illustrates why system behavior deserves attention beyond test results. Its discovery followed unusual load that made a machine unresponsive while a researcher tested a plugin pulling LiteLLM in transitively. This leaves the cause unproven as far as an upgrade agent is concerned, but shows how watching only spend and passing tests can miss trouble.
The earlier safeguards address this adversarial dimension too. A release cooldown avoids immediately consuming every new version, while restricted egress limits unexpected destinations where the runner platform supports it. Repository documentation, issue bodies, and dependency changelogs must also be treated as untrusted input because they can hold prompt-injection instructions. The agent needs to read that material to do its job, but reading it must not grant it authority. Monitor unusual system behavior as well as the workflow’s normal outputs.
Human review checkpoints and the tiered autonomy model
Human oversight belongs at the boundary between a verified proposal and an accepted change. Autonomy should follow reversibility. Some teams will start by having a human review every PR an agent opens, which makes sense while they check whether the gates catch bad work.
Tier 1 makes dependency version bumps eligible for independent auto-merge when all CI checks pass, no production code changes, and the changeset stays within its size budget. These are starting conditions to adjust for the team’s risk tolerance. Patch and minor upgrades often meet these checks, while a human must review major upgrades that touch production code. The agent still cannot approve or merge its own work.
Tier 3 remains human-only for schema migrations, authentication and authorization, payment logic, infrastructure-as-code, pipeline configuration, and agent configuration or permissions. For a reviewable agent PR, the lesson is to read the tests first. If no test proves the change works, that is the finding and review stops there. Read the diff next, rather than relying on the description’s confidence language. Scope enforcement should already have blocked unrelated reformatting, renaming, and comment edits, because together they make the intended repair harder to check.
Keeping the pipeline maintainable as the workflow matures
A launched workflow needs maintenance as dependencies, configuration, and model behavior evolve. Keep CI workflows as thin orchestration wrappers over a project Makefile so developers can reproduce the steps locally. Red Hat identifies this pattern as a way to avoid “it passed on my machine” surprises. A failed check should be reproducible without another commit merely to rerun CI.
The same guidance describes a smaller PR evaluation set and longer nightly evaluations for its it-self-service-agent quickstart. That split conserves tokens during review while producing longer-horizon error data. For promotion workflows, validate version references across the Makefile, Helm chart, and values files before opening a PR to main. Updating one reference while forgetting another recreates the inconsistency the upgrade workflow is supposed to remove.
Stateful sessions need infrastructure beneath those checks. A purpose-built agent runtime can separate memory tiers, resume work after a crash, and maintain an append-only log for debugging, while conventional CI handles reproducible builds and test execution. Keeping these responsibilities distinct helps the pipeline stay thin and the agent’s behavior observable.
Expansion should depend on demonstrated control. Start with patch-version bumps in one service, establish that the gate catches scope creep and test-laundering, then extend to minor bumps and additional services. The basis for granting more autonomy is not a run of convincing summaries, but evidence that the workflow rejects work it was never authorized to accept.


