Est.

Why the VM That Runs Your Agent Task Should Not Outlive the Pull Request

Coding agent VMs should die with the PR, and context can live elsewhere.

· 8 min read
Cover illustration for “Why the VM That Runs Your Agent Task Should Not Outlive the Pull Request”
Slack Agent Workflows · November 14, 2026 · 8 min read · 1,781 words

A bring-your-own API key cloud coding agent runner should treat workspace lifetime as a security boundary. Durable context belongs in the integration layer.

Why a VM that outlives its pull request is a security liability, not a convenience

Teams already use coding agents to work in real repositories with real credentials. These agents receive shell access, package-manager access, network connectivity, API tokens, and permission to create branches or open pull requests. They are privileged automation. Their execution environments therefore need controls suited to the capabilities they hold, including a defined point at which those capabilities stop being available.

When the PR is ready but the VM remains active, secrets can remain in environment variables and files, network connections can stay open, and residual state remains available to another task or an attacker. Logs, prompts, tool outputs, and generated artifacts may also store sensitive information unless the product stops them from doing so. Keeping the machine alive extends that exposure without advancing the completed task. Enterprises need policies governing what enters the workspace, how long it persists, and where the agent can send it. The strongest objection is that persistent VMs save setup time, but that argument leaves the security cost outside the calculation.

What keeps agent VMs alive longer than necessary

The work of installing dependencies and setting up tools gives teams a reason to keep workspaces. Spending minutes on setup again feels wasteful when a machine is already set up. Persistence is often an operational shortcut. Long-lived personal tokens follow a similar pattern because short-lived credential issuance requires additional infrastructure. Leaving a token in an environment variable is easier than wiring up an OIDC provider.

OpenAI’s Codex Cloud made the setup tradeoff explicit at DevDay 2026 through published development environments. These bundle repositories, dependencies, tools, and access settings into a prepared filesystem that new tasks reuse. Existing tasks instead continue with their saved files, including uncommitted changes and installed tools. That distinction separates reusable preparation from accumulated task state. It also introduces drift because new tasks keep starting from a stale snapshot if the environment is not republished after a dependency upgrade.

Application-level restrictions do not resolve these structural incentives. Blocking curl, for example, does not prevent a goal-directed agent from writing a Python script that performs the same request. The intended restriction has not become an enforced boundary. The environment must constrain the system action, regardless of how the agent attempts it.

What the right architecture actually enforces: workspace lifetime as a security primitive

The design response begins with three concrete requirements. Each workspace starts from a known template, receives only the credentials needed for its task, and terminates when the PR is ready for review. “Ephemeral” must describe enforced behavior. The task defines the workspace’s scope, while convenience does not extend its lifetime.

The isolation requirement is a microVM or full VM with its own kernel. A separate guest kernel reduces the blast radius of a compromised process. Credential scoping then limits the authority available inside that boundary. Secrets should be injected per task, last only a short time, and be tied to service identities. Anything placed inside the sandbox should be treated as readable and transmissible by the code running there.

These controls also need a set point at which the execution environment is removed because its work has ended. Egress restrictions are still needed while the task runs. Codex Cloud illustrates a layered approach through environment internet settings and workspace-level administrator policy, where a workspace-level allowance does not override an environment restriction. Such controls must operate deterministically outside the model’s reasoning. A short-lived VM with unrestricted outbound access can still expose its credentials before termination.

The OWASP Top 10 for LLM Applications identifies Excessive Agency as LLM06:2025, covering functionality, permissions, or autonomy beyond what a task needs. Task-scoped execution directly addresses that risk class. Builds, tests, security scans, and policy checks should run in the ephemeral environment before the PR opens, without allowing the agent to redefine acceptance criteria when a check fails.

How the major coding agents handle VM lifetime today, and where the gaps are

The major coding agents use isolated execution, but isolation alone does not set a point at which access ends. Cursor Cloud Agents run in isolated VMs dedicated to a session. Cursor’s engineering team described the work of adding secret redaction, network policies, and credential management as “essentially enterprise IT for agents”. Credential handling and teardown still require explicit attention.

GitHub Copilot coding agent operates inside GitHub Actions with internet access limited to a trusted destination list. Its CI/CD workflows need a human to approve them by default, though repository administrators can turn that requirement off. This is a useful process control. It governs progression through the workflow rather than establishing a strict VM termination boundary at PR creation. The two controls address different risks and should not be treated as substitutes.

Codex Cloud’s published environments introduce a separate question about what is reused. Filesystems that are already set up help tasks start faster, while credentials owned by the environment and VPN connections can give users shared access to services when an Enterprise environment is shared workspace-wide. The security outcome depends on scope and timely republishing. Across these approaches, PR creation is not itself an enforced credential-expiry event, and injected secrets remain accessible until the runner exits. Moving execution off developer laptops protects local files and credentials, but residual task state still requires per-task instantiation and termination.

Why parallel agent workflows make strict VM lifetime enforcement more urgent, not less

Parallel execution multiplies the number of environments holding access. A common pattern assigns features as vertical slices, gives each its own git worktree, and launches an agent per branch. That pattern keeps agents isolated only if they cannot read each other’s state, which is harder to ensure when they share persistent environments.

More PRs can arrive than reviewers can examine carefully, encouraging faster merges and less scrutiny of sensitive artifacts. CircleCI’s guidance uses the number of open PRs awaiting review to guide parallel-agent scaling, rather than the number of agents that can be launched. This connects execution capacity to the actual unit of delivery. It also prevents available compute from becoming the only constraint on work in progress.

A Sentry alert, Linear issue, or webhook can initiate work without a person monitoring the session. No human handoff necessarily prompts someone to stop the machine. Automatic termination on PR creation must therefore be part of the architecture. Otherwise, unattended execution can leave access active after the agent has delivered its output.

How integrations with Slack, Linear, GitHub, and Sentry preserve context without persisting the VM

The strongest context argument for persistence confuses the workspace with the systems that explain the work. Linear Agent, introduced in March 2026, investigates issues using specifications, codebase history, and Sentry or Datadog data gathered through MCP before a workspace opens. Coinbase’s Forge, built on Linear’s Agent SDK, described Linear as “the place where agents go to get their bearings before starting a task”. The workspace can therefore start informed without inheriting another task’s machine state.

Ramp’s Inspect, built on Linear’s API, connects specifications, customer feedback, and code. The agent writes more than half of the PRs Ramp merges. Its useful context resides in Linear. Sentry’s Seer agent, described in April 2026, likewise starts with a production alert, looks for the root cause, and proposes a fix. Sentry’s event data retains the diagnostic context, allowing execution to begin in a clean VM and end at PR creation.

Codex’s bug-triage workflow recommends combining Slack reports, Sentry alerts, and GitHub failures when they describe the same bug. Aggregation happens in the integration layer rather than through a machine left running to collect observations. This changes where teams need to invest. Rich Linear issues, structured Sentry alert context, and well-scoped GitHub workflows support useful output from shorter-lived environments. Preserving the source context removes the need to preserve the execution surface.

What governance and auditability require from ephemeral workspaces at enterprise scale

A workspace scoped to one task gives audit records a clear boundary. Enterprise governance needs to identify who initiated the task, what the agent accessed, which tools it invoked, what changed, which approvals occurred, and what verification ran. An environment that stays alive for a long time mixes those activities from different changes. Task-scoped execution instead associates them with a discrete PR and a defined execution period.

The execution environment ends, while its audit record remains available for review. Codex’s architecture also distinguishes execution paths for compliance purposes. Local execution is not covered by its compliance API, even in sandboxed mode, so cloud execution is the fully auditable path under that model.

Deployment location is a separate governance choice. Infrastructure that is self-hosted or VPC-deployed can meet strict data-residency requirements while still ending each task’s environment in the same way and keeping audit logs inside the customer’s network. SOC 2 controls, SCIM provisioning, audit logs, and secret management should be platform capabilities. Missing governance tooling creates pressure to keep environments alive while controls catch up. One task, one workspace, one PR, and one record instead align delivery with the unit an auditor needs to examine.

How to adopt ephemeral-per-PR execution in a team already running agents

For a team already running agents, adoption should begin with credential hygiene. Check the secrets now stored in agent environment variables, replace long-lived personal tokens with short-lived service identities or OIDC credentials, and make sure secrets are injected per task. Existing agent tooling need not be replaced. The immediate objective is to reduce retained authority before changing how workspaces start and stop.

Next, encode dependency installation and service startup in a reproducible script or published environment definition. For published environments, republishing after changes is part of maintaining that definition. Use platform configuration or a post-task hook to make sure termination happens when the PR is created. Idle timeouts are insufficient because they leave a gap between task completion and teardown.

Context preparation should precede higher agent volume. Invest in rich Linear issue descriptions, structured Sentry alert metadata, and well-scoped GitHub workflows so that a fresh workspace receives the information needed to act. Set the number of parallel agents based on how many PRs are waiting for review. For scheduled and event-driven runs, confirm automatic termination on PR creation or add a termination step to the automation definition.

Finally, treat the recording or replay of each agent session as a first-class output beside the PR. A destroyed workspace should leave a complete record of its actions. This separates evidence retention from machine retention. The PR remains reviewable, the task remains auditable, and the credentials no longer need a running environment in which to persist.

Sources

  1. Security Risks in Tool-Enabled AI Agents: A Systematic Analysis of Privileged Execution Environments

More in Slack Agent Workflows