All posts

Policy as Code for Tool-Using Agents

Are you wondering how to keep tool‑using agents governed by policy as code the same way you govern human operators? Many teams hand a CI/CD runner, a backup script, or an AI‑assisted code reviewer a static credential and assume the agent will behave like a well‑intentioned user. In practice, those agents often run with broad, standing permissions, bypass manual reviews, and leave no trace of what they actually did. When an agent connects directly to a database, a Kubernetes cluster, or an SSH h

Free White Paper

Pulumi Policy as Code + AI Tool Use Governance: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Are you wondering how to keep tool‑using agents governed by policy as code the same way you govern human operators? Many teams hand a CI/CD runner, a backup script, or an AI‑assisted code reviewer a static credential and assume the agent will behave like a well‑intentioned user. In practice, those agents often run with broad, standing permissions, bypass manual reviews, and leave no trace of what they actually did.

When an agent connects directly to a database, a Kubernetes cluster, or an SSH host, the request travels straight from the automation runner to the target. The identity that initiated the request is verified, but the enforcement point lives on the target itself. The target sees a privileged service account, executes the command, and returns data without any intermediate guardrails. If the agent mis‑behaves, the organization loses visibility, cannot apply fine‑grained rules, and struggles to prove compliance.

This is the starting state for most organizations: tool‑using agents are granted static credentials, they connect directly to infrastructure, and there is no real audit trail or inline protection. The problem is uncomfortable, but it is common.

Why policy as code alone is not enough

Policy as code lets you describe allowed actions in a declarative form, e.g., "agents may read from the analytics schema but cannot drop tables." However, without an enforcement layer that sits on the actual data path, those policies remain inert. The setup, OIDC tokens, service accounts, least‑privilege roles, decides who may start a session, but it does not guarantee that every command complies with the declared policy.

In this precondition, the policy definition is in place, but the request still reaches the target directly, with no real‑time check, no masking of sensitive fields, and no way to block a dangerous command. The organization still lacks evidence of who ran what, when, and why.

hoop.dev as the data‑path enforcement point

hoop.dev is built to sit between the agent and the infrastructure it accesses. By proxying the connection, it becomes the only place where enforcement can happen. When an agent initiates a session, hoop.dev authenticates the identity, looks up the relevant policy as code, and applies the rules before any traffic reaches the target.

  • hoop.dev records each session, creating an audit trail that can be replayed for investigations.
  • hoop.dev masks sensitive fields in responses, ensuring that downstream logs never expose secrets or PII.
  • hoop.dev blocks commands that violate the policy, returning a clear error to the agent without ever touching the target.
  • hoop.dev can trigger just‑in‑time approval workflows for high‑risk operations, pausing execution until a human reviewer approves.

All of these outcomes exist because hoop.dev sits in the data path. The enforcement outcomes are not achieved by the identity provider or by the static credentials alone; they require the gateway to inspect and act on each request.

Continue reading? Get the full guide.

Pulumi Policy as Code + AI Tool Use Governance: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

How the enforcement flow works

1. The agent presents an OIDC token to hoop.dev. The gateway verifies the token and extracts group membership.

2. hoop.dev loads the applicable policy as code for that identity and the target resource.

3. Before forwarding any command, hoop.dev evaluates it against the policy. If the command is allowed, it is proxied; if not, hoop.dev blocks it and logs the attempt.

4. Responses from the target pass back through hoop.dev, where any fields marked for masking are redacted in real time.

5. The entire session, including approvals and blocked attempts, is stored for replay and audit.

What to watch for when applying policy as code to agents

  • Policy granularity: Write rules that map to the exact protocol commands used by the agent. Overly broad statements can let risky actions slip through.
  • Dynamic secrets: If agents rely on short‑lived credentials, ensure the gateway can rotate them without breaking the policy evaluation.
  • Approval fatigue: Use just‑in‑time approvals sparingly; automate low‑risk actions while reserving human review for high‑impact changes.
  • Audit retention: Align session recording retention with compliance requirements; hoop.dev provides the raw data, but the organization must define the retention schedule.

Getting started with hoop.dev

To put policy as code into practice for your tool‑using agents, start by deploying hoop.dev in your network. The quick‑start guide walks you through a Docker Compose deployment, OIDC configuration, and registering a sample PostgreSQL connection. Once the gateway is running, define your policies in a YAML file and point the gateway to it. Detailed guidance is available in the getting‑started documentation and the broader learn section.

Explore the source code, contribute improvements, or adapt the gateway to your environment on GitHub: hoop.dev repository.

FAQ

Do I need to change my existing agents?

No. Agents keep using their standard clients (psql, kubectl, ssh, etc.). The only change is that they connect through the hoop.dev endpoint instead of the target directly.

Can hoop.dev enforce policies on encrypted traffic?

Yes. Because hoop.dev terminates the protocol at layer 7, it can inspect commands and responses even when the underlying transport is TLS.

What happens if an agent tries to bypass hoop.dev?

By design, the target resources are configured to accept connections only from the gateway’s service identity. Without a direct network path, the agent cannot reach the resource without going through hoop.dev.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts