All posts

Human-in-the-Loop Approval Best Practices for Subagents

Do you trust a subagent to run privileged commands without a human-in-the-loop approval? Most teams today spin up subagents, short‑lived processes that inherit the same service credentials as the parent workload. The subagent can reach databases, Kubernetes clusters, or SSH endpoints directly, using a static token that never changes. Because the credential is baked into the deployment artifact, any compromise of the parent automatically grants the subagent unrestricted access. Auditors see a si

Free White Paper

Human-in-the-Loop Approvals + Approval Chains & Escalation: The Complete Guide

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

Free. No spam. Unsubscribe anytime.

Do you trust a subagent to run privileged commands without a human-in-the-loop approval?

Most teams today spin up subagents, short‑lived processes that inherit the same service credentials as the parent workload. The subagent can reach databases, Kubernetes clusters, or SSH endpoints directly, using a static token that never changes. Because the credential is baked into the deployment artifact, any compromise of the parent automatically grants the subagent unrestricted access. Auditors see a single long‑lived credential, and engineers have no visibility into which commands the subagent actually executed.

Introducing a human‑in‑the‑loop step sounds simple: require a manager to approve each subagent action before it touches production. In practice, the request still travels straight to the target system, bypassing any enforcement point. The approval record lives in a ticketing system, while the subagent continues to use the same credential and can issue commands even if the ticket is revoked. No real‑time audit trail, no inline data masking, and no way to block a dangerous command once the subagent is connected.

Why the data path must host human-in-the-loop approval

To make approval effective, the check has to sit where the subagent’s traffic flows. That means placing a gateway between the subagent identity and the infrastructure resource. The gateway authenticates the subagent’s OIDC token (the setup layer) and then inspects every protocol message (the data path). Only the gateway can enforce that a command is allowed, that a session is recorded, and that sensitive fields are masked before they reach the backend.

When the gateway is the sole enforcement point, the following outcomes become guaranteed:

  • hoop.dev requires an explicit human‑in‑the‑loop approval before forwarding a subagent request.
  • hoop.dev records the entire subagent session for replay and forensic analysis.
  • hoop.dev masks sensitive response fields (for example, passwords or personal data) in real time.
  • hoop.dev can abort a command that violates a policy, preventing accidental data loss.

Practical best‑practice checklist

Below is a step‑by‑step checklist that aligns the three attribution categories, setup, data path, and enforcement outcomes, so that human‑in‑the‑loop approval works reliably for subagents.

1. Define a minimal subagent identity

Start with a service account that has only the permissions the subagent truly needs. Use OIDC or SAML to issue short‑lived tokens, and avoid embedding static keys in images. This is the setup phase: the identity decides who the subagent is, but it does not enforce any policy.

2. Register the subagent connection in the gateway

Tell the gateway which target (database, Kubernetes API, SSH host) the subagent will reach. The registration stores the target credentials inside the gateway, so the subagent never sees them. This creates the data path that all traffic must cross.

3. Create an approval policy

Specify the conditions that trigger a human‑in‑the‑loop request: command patterns, target resources, or time‑of‑day windows. Policies live in the gateway configuration, not in the subagent code. When a subagent initiates a connection, hoop.dev evaluates the policy and, if needed, sends an approval request to the designated approvers.

Continue reading? Get the full guide.

Human-in-the-Loop Approvals + Approval Chains & Escalation: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

4. Use just‑in‑time (JIT) approval

Require an approver to grant access for a single operation or a short time slice. hoop.dev enforces the JIT grant at the gateway, and the grant expires automatically. This limits the window of exposure and ensures that stale approvals cannot be reused.

5. Enforce inline masking

Identify fields that must never leave the gateway in clear text, passwords, tokens, PII. Configure the gateway to replace those values with placeholders before they reach the subagent. Because hoop.dev performs the masking in the data path, the subagent never sees the raw data.

6. Record and retain sessions

Enable session recording for every subagent interaction. hoop.dev writes an audit log entry for each command, its parameters, and the response (after masking). Retention policies can be set to satisfy audit requirements.

7. Review and rotate credentials regularly

Even though the gateway stores the target credentials, they should be rotated on a schedule. When a rotation occurs, update the gateway configuration and invalidate any existing subagent tokens. This keeps the setup layer fresh and reduces the impact of a compromised token.

Common pitfalls and how to avoid them

Pitfall 1: Relying on ticket status alone. Approvers may close a ticket, but the subagent can keep the connection open. The remedy is to let hoop.dev enforce the approval lifecycle, automatically terminating the session when the ticket expires.

Pitfall 2: Storing credentials in the subagent image. If the image is cached, the secret persists beyond its intended life. Store all target credentials exclusively in the gateway and use short‑lived OIDC tokens for the subagent.

Pitfall 3: Ignoring audit log integrity. Auditors need proof that logs have not been tampered with. By letting hoop.dev generate the logs at the data path, you ensure the logs reflect the true traffic, independent of the subagent process.

Getting started

Review the getting‑started guide for deploying the gateway and registering a subagent connection. The learn section contains deeper discussions of approval policies, masking rules, and session replay.

FAQ

What exactly is a subagent?

A subagent is a short‑lived process that runs on behalf of a parent workload, using the same service identity to reach downstream infrastructure. It is typically launched by automation, CI/CD pipelines, or AI assistants.

How does human‑in‑the‑loop approval work with hoop.dev?

When the subagent initiates a request, hoop.dev checks the configured policy. If the policy requires approval, hoop.dev pauses the request and forwards an approval prompt to the designated approvers. Only after an approver clicks “allow” does hoop.dev forward the traffic to the target.

What audit data is retained?

hoop.dev records every command, its arguments, the identity that issued it, and the masked response. These records are written to an audit log that can be queried for forensic investigations or compliance reporting.

Ready to tighten control over your subagents? Explore the source code and contribute on GitHub.

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