Per-Channel and Per-Repo Agent Confinement Patterns
Scoping each agent to one channel or repo caps the damage a failure can do.

A single agent request can start in Slack, open a pull request on GitHub, touch a payment record in Stripe, and write a summary back to a support channel, all in one round-trip. When it is compromised or simply misbehaves, the chain becomes a map of everything it can damage, because an agent's reach at the moment of failure is exactly as wide as the access it was carrying at the moment it started.
That reach is the blast radius, and its size has a direct cause: the agent authenticates with a shared service account that carries far more access than its task needs. The State of AI Agent Security 2026 finds that agents are routinely deployed with access to systems, datasets, or API endpoints well beyond what their task requires, and it traces the pattern back to shared service accounts and inherited credentials as the cause. It is a provisioning decision made before the agent ever runs.
The same report finds that monitoring coverage has barely improved even as agent estates have roughly doubled in a quarter, so the number of over-privileged, unmonitored agents is growing fast in raw terms, not just as a share of the fleet. If a rogue agent gets caught only after it has already touched a database or posted to the wrong channel, the blast radius hasn't shrunk by then. The engineering answer has to come earlier: restrict what the agent can reach before it has the chance to misbehave, by binding its identity and credentials to the exact scope of the task at hand. Per-channel and per-repo confinement patterns do exactly this. They make blast-radius limits a structural property of how you deploy the agent, instead of a policy you just hope gets enforced at runtime.
What "scope-bounded agent identity" means
With scope-bounded agent identity, each agent instance holds credentials and API access scoped to exactly the surface its task requires: nothing more, and nothing inherited from a parent process or a shared account. If an agent is built to open pull requests against one repository, its token should open pull requests against that repository and no other.
The dominant failure mode this replaces is familiar to anyone who has provisioned a service account and moved on: an agent authenticates through a shared account and inherits whatever that account happens to hold, which is usually far more than any single task needs. The same logic holds for code: an agent that needs to open one pull request on one repository but authenticates with an org-wide token can modify any repository that token covers, whether or not the agent's task ever mentioned it.
Closing that gap takes three things holding true at once: the identity the agent claims, the credential it uses to back up that claim, and the policy the API enforces against that credential all have to line up on the same narrow scope. When identity, credential, and policy agree, the worst a misbehaving agent can do is damage confined to its own scope. That is the engineering definition of blast-radius containment, and it is the standard the per-channel and per-repo patterns are built to meet.
Per-channel confinement: binding an agent's identity to a single communication surface
Per-channel confinement gives each channel its own agent identity, with tool access cut down by an allow/deny policy to only the operations that channel's task actually calls for. If an agent monitors a support channel and posts summaries, it needs read access on that channel and permission to post to it. It has no business holding a token that lets it join new channels, invite users, or read direct messages, even if the platform would allow it.
The allow/deny tool policy layer is what makes that restriction stick at the API level. OpenClaw also supports a non-main mode that sandboxes sessions outside the primary one, and that closes off a third path by which an agent in a side channel could try to escalate into the main session's context.
Stacking those three together boxes a compromised per-channel agent in three separate ways: it can only touch the channel it was given, it can only use the tools it was allowed, and it can only act from inside its own sandbox. Verifying that the boundaries actually hold, though, means testing them against something that behaves like the real surface. A stateful Slack simulator, one that keeps track of which channels exist, which messages have already been posted, and which permissions are currently in effect, lets a team confirm that an agent's tool calls stay inside its scoped allow list before any real Slack token is ever issued.
Per-repo confinement: encoding isolation level in configuration so it travels with the code
The insight that makes per-repo confinement durable rather than ad hoc is simple: write the isolation level into the repository's own configuration, and the policy travels wherever the code travels. A developer who clones the repository and runs the agent locally inherits the same isolation level the CI job enforces, because the rule lives in a file in the repo rather than in a setting someone has to remember to apply. That portability is what separates a confinement pattern that holds up over forks, clones, and new environments from one that only works as long as someone keeps re-applying it by hand.
This is not a theoretical arrangement. Write the isolation level into that file, and the agent runs under it on every machine that clones the repo.
The same census found that commit-deployed, in-editor agents, Claude Code among them, appear mostly in maintenance work: patches, refactors, dependency bumps, and the long tail of incremental change. Claude Code's changelog for version 2.1.285 states that project settings cannot widen or turn off an admin-required sandbox, replace the proxy behind a managed deny list, extend a strict allowlist, or reopen managed read-denies. That invariant, lower-trust configuration cannot override higher-trust policy, is what keeps per-repo confinement sound. Verifying the policy before granting live credentials works the same way it does for Slack: a stateful GitHub simulator that enforces repo-scoped token permissions, allowing a pull request on one repository and rejecting the identical call on another, lets a team confirm the isolation actually holds before any real token goes out.
Stateful, scope-aware testing at each rung of the isolation ladder
If a pattern is never tested against the API surface it claims to confine, it doesn't survive contact with reality. A policy can say the agent is scoped to one channel or one repository while the credential behind it, or the tool definition calling it, quietly allows more. The gap between what the policy says and what the credential actually permits is where the isolation ladder breaks, and it breaks silently, because nothing about a working agent call announces that it was never supposed to succeed.
Stateless mocks cannot surface this kind of failure. A stub that returns the same canned response no matter what token is presented has no way of telling anyone whether that token's actual scope would be accepted by the live API for that particular call. A stateful simulator closes that gap: it enforces the same permission model the real API enforces, and it rejects any call a scoped token wouldn't actually be allowed to make. That rejection is the test. If the simulator lets a call through that the real API would have blocked, the confinement policy has already failed, just not yet in a place anyone can see.
That invisibility compounds a problem already documented at the fleet level: agent monitoring coverage remains well below complete, so a scope violation that doesn't trip an immediate error can pass through several CI cycles before anyone notices it happened. Confirming the policy once at launch isn't enough. The simulator enforcing that policy has to be checked against the live API on an ongoing basis, for the same reason any test fixture needs to track the system it's standing in for.
Integrating per-surface confinement checks into CI so isolation regressions are caught on every pull request
A confinement policy is only as durable as the last time someone checked it still held, so it needs to be tested on every change that could plausibly break it. If a CI job runs the agent's scoped tool calls against a stateful simulator and fails the build the moment any call falls outside the declared scope, it turns the isolation ladder from a documented intention into an enforced contract.
Several kinds of changes can break a confinement policy without touching anything else in the codebase: a new tool added to the agent's allow list that quietly inherits broader scope than intended, a dependency update that shifts the permission model of an underlying SDK, a config file edit that widens an isolation level without anyone meaning to, or a provider-side permission change that makes a previously scoped token broader overnight. Instead, they show up as a confinement check that used to pass and now shouldn't.
The verification pattern to build into CI records exactly four things on every run: which tools were called, which credentials were presented, which calls were rejected, and which isolation level was enforced. The mechanism that makes the check actually gate anything is the exit code: the CI step exits 0 when every scoped call passes and every out-of-scope call is correctly rejected, and exits 1 the moment either condition fails. The State of AI Agent Security 2026 notes that pre-deployment controls have barely kept pace with the growth in agent estates. Putting confinement verification directly in CI is the mechanism that lets pre-deployment control grow at the same rate agent adoption does.
Applying confinement patterns to AI agents in RL environments and agentic eval pipelines
RL training and agent evaluation pipelines push per-surface confinement to its hardest case and its highest stakes at once. Thousands of agent instances can run in parallel, each calling out to external APIs, and no one is watching closely enough to catch a scope violation before it spreads across an entire training run.
Reproducibility is non-negotiable in that setting: the same action taken from the same state has to produce the same observation every time, or the reward signal the whole run depends on gets corrupted. Live APIs, with their rate limits, their occasional non-determinism, and their stateful side effects, cannot guarantee that. Scale makes the problem worse before it makes it better. A credential scoped incorrectly will generate thousands of out-of-scope calls before a single one gets flagged.
The fix follows the same architecture used in production, scaled out: each container gets its own simulator instance with its own scoped state, a GitHub simulator that exposes only the repositories that particular agent is allowed to touch, a Slack simulator that exposes only the channels in its scope. The controllable state inside a simulator also makes fault injection practical at this scale in a way live APIs don't allow: a simulator can be set to return a 429, a 503, or a malformed response at a specific step in a rollout, producing exactly the labeled failure cases an RL agent needs to learn how to handle. The architecture protecting a production Slack or GitHub integration, scope-bounded identity, a stateful simulator, CI verification, turns out to be the right foundation for an RL environment too, because what RL training demands, determinism, isolation, and controllable state, is a strict superset of what production already requires.
A practical starting point for teams adopting per-channel and per-repo confinement today
The easiest confinement baseline to maintain is the one built narrow from the start, not the one retrofitted after an agent is already running in production. For every surface an agent will touch, the first step is to write down the exact operations its task requires and provision a credential that covers only those operations, resisting the instinct to start broad "for convenience" and narrow the scope down later, which rarely happens once the agent is already working.
Once a team defines that scope, it should write it into the repository's own agent configuration, an AGENTS.md file or an equivalent fleet-config entry, so the isolation level is set before the agent ever runs in CI, and it travels automatically with every clone and fork of the code. From there, the agent's actual tool calls need to run against a stateful simulator for each surface it touches, whether that's Slack, GitHub, Stripe, PayPal, or any other API in scope, with an explicit assertion that out-of-scope calls get rejected. The CI build should then gate on the simulator's exit code: a passing build means the agent's tool calls stayed inside the scope declared for that pull request, and a failing build surfaces a scope regression before any live credential is ever touched.
For teams running RL or evaluation pipelines, the same pattern extends outward rather than changing shape: one simulator instance per container, pre-seeded with the state relevant to that particular rollout, with fault injection configured for whatever failure cases the agent is meant to learn from. None of this holds up, though, if the simulator itself drifts from the real API it's standing in for. If a simulator doesn't enforce the same permission model as the live service, its CI checks pass cleanly but tell a team nothing true about what will happen in production, so you need to keep verifying the simulator against the live API just as the confinement policy itself requires. That continuous check is what keeps the whole structure, scope-bounded identity, per-channel and per-repo confinement, and CI-gated verification, meaningful months after it was first built.


