DEV Community

Cover image for Your AI Agents Have Root Access and Nobody's Watching: A Governance Framework That Won't Kill Velocity
Michael
Michael

Posted on Originally published at getmichaelai.com

Your AI Agents Have Root Access and Nobody's Watching: A Governance Framework That Won't Kill Velocity

Most teams deploy AI agents the way they'd hand a new intern the production database password. The agent can read your CRM, send emails, trigger refunds, and write to your knowledge base. And nobody has a clear answer to a simple question: what happens when it does the wrong thing at 2am?

Governance sounds like the word that shows up right before a project dies in committee. It doesn't have to be. Done right, it's the guardrails that let you ship agents faster because you're not terrified of what they'll do in production.

Here's a framework we use with B2B clients. It's four layers, and none of them require a compliance department.

Layer 1: Scoped Identity, Not Shared Keys

The first mistake is giving every agent the same API key with full permissions. When something breaks, you can't tell which agent did what, and you can't revoke access without taking everything down.

Give each agent its own identity with the minimum scope it needs. A support triage agent reads tickets. It does not get write access to billing.

# Bad: one god-key for everything
agent = Agent(api_key=os.environ["MASTER_KEY"])

# Better: scoped, per-agent credentials
AGENT_SCOPES = {
    "support_triage": ["tickets:read", "tickets:tag", "kb:read"],
    "refund_processor": ["orders:read", "refunds:create:<=100"],
}

def build_agent(name):
    scopes = AGENT_SCOPES[name]
    token = issue_scoped_token(agent=name, scopes=scopes, ttl=3600)
    return Agent(token=token, allowed_actions=scopes)
Enter fullscreen mode Exit fullscreen mode

Notice refunds:create:<=100. Scope isn't just which action, it's the boundary. An agent that can issue refunds under $100 without approval and escalates anything above is a very different risk profile than one with unlimited authority.

Layer 2: Human-in-the-Loop Where It Counts

Not every action needs approval. That's the trap teams fall into: they either fully automate or they route everything to a human and destroy the point of automation.

Classify actions by reversibility and blast radius.

  • Auto-execute: reversible, low impact. Tagging a ticket, drafting a reply, updating an internal note.
  • Approve-then-execute: irreversible or customer-facing. Sending an external email, issuing a refund, deleting records.
  • Never automate: legal commitments, contract terms, anything touching regulated data without explicit sign-off.
def execute_action(action, agent):
    policy = get_policy(action.type)
    if policy == "auto":
        return action.run()
    if policy == "approve":
        request = queue_for_approval(action, agent=agent.name)
        return {"status": "pending", "request_id": request.id}
    raise PolicyViolation(f"{action.type} cannot be automated")
Enter fullscreen mode Exit fullscreen mode

The approval queue should be fast. If a human takes six hours to click approve, people will disable it. Push approvals to Slack with one-click accept/reject and a summary of what the agent wants to do and why.

Layer 3: Log Everything, Make It Queryable

When a customer complains that your agent promised something insane, you need to reconstruct exactly what happened: the input, the reasoning, the tools called, and the output.

Structured logs are non-negotiable. Free-text logs you can't query are just noise.

function logAgentStep(ctx) {
  logger.info({
    agent: ctx.agentName,
    trace_id: ctx.traceId,
    action: ctx.action,
    inputs: redactPII(ctx.inputs),
    tools_called: ctx.tools,
    tokens: ctx.tokenUsage,
    decision: ctx.output,
    latency_ms: ctx.latency,
    ts: Date.now(),
  });
}
Enter fullscreen mode Exit fullscreen mode

Two things matter here. First, trace_id ties every step of a single agent run together so you can replay it. Second, redactPII strips sensitive data before it hits your logging pipeline, which keeps you out of trouble with your own compliance rules.

When an incident happens, you should be able to run one query and see every action that agent took in the last hour.

Layer 4: Continuous Evaluation, Not One-Time Testing

Agents drift. The model gets updated, your prompt gets tweaked, a new tool gets added, and suddenly behavior changes in ways your original tests never caught.

Run a standing eval suite against every agent on a schedule and before every deploy. Include:

  • Golden cases: known inputs with expected outputs. Catches regressions.
  • Adversarial cases: prompt injection attempts, jailbreaks, edge cases. Catches security holes.
  • Policy cases: inputs designed to tempt the agent into a forbidden action. Confirms your guardrails hold.

If an agent that should never issue a refund over $100 does exactly that in your eval, that's a blocked deploy, not a warning to look at later.

Making It Real Without Slowing Down

The fear is that governance means process, and process means slow. It doesn't, if you build it into the deployment path instead of bolting it on afterward.

Start with the highest-risk agent, not all of them. Give it a scoped identity, wrap its irreversible actions in approvals, log every step, and add a small eval suite. That's a day of work, and it turns a liability into something you can actually defend in a security review.

The teams that win with AI agents aren't the ones who move slowest out of caution. They're the ones who built enough control that they can move fast without flinching. Governance isn't the brake. It's the thing that lets you take your foot off it.

If you're deploying agents into real B2B workflows and want the guardrails built in from day one, that's exactly the kind of system we design at Michael AI.


Originally published at getmichaelai.com

Top comments (0)