惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
M
MIT News - Artificial intelligence
S
SegmentFault 最新的问题
博客园 - 叶小钗
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
U
Unit 42
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Human-in-the-Loop: The Runtime Enforcement of requires_ap...
tercel · 2026-05-16 · via DEV Community

As AI Agents gain more autonomy, a fundamental fear has taken hold in the enterprise: "What if the Agent does something it shouldn't?"

We’ve all seen the warnings in system prompts: "Please be careful when deleting data." But as every seasoned engineer knows, a prompt is not a security policy. If you want to prevent an AI from accidentally triggering a production deployment or wiping a database, you need a hard, runtime "Kill Switch."

In the apcore protocol, we call this the Approval Gate. In this sixteenth article, we explore how the requires_approval annotation brings "Human-in-the-Loop" (HITL) directly into the heart of the execution pipeline.


Why Autonomy Needs a Brake Pedal

Autonomous Agents are designed to loop: they plan, execute, observe, and repeat. The problem arises during the "Execute" phase. If an Agent decides that the best way to "optimize disk space" is to delete your var/log directory, it will try to do so instantly.

Traditional systems try to solve this with prompt engineering or post-execution auditing. Both are too slow.

At apcore, we implement HITL at Step 5 of our 11-step pipeline. Before the validation runs, and long before your code is executed, the Executor checks for the "Approval" flag.


The requires_approval Annotation

Marking a module as "High Stakes" is a single-line operation in apcore:

@module(id="ops.deploy", description="Deploy to production.")
@annotations(requires_approval=True, destructive=True)
def deploy(env: str):
    # Logic...

Enter fullscreen mode Exit fullscreen mode

When this module is invoked, the apcore Executor doesn't run the code. Instead, it halts and triggers an ApprovalHandler.


Pluggable Approval Handlers

The beauty of apcore is that the "Human" doesn't have to be in any specific UI. Because apcore is a protocol, the approval request is projected onto whichever Surface the caller is using:

1. The CLI Surface

If you are running a module via apcore-cli, the terminal will pause and ask:
Module 'ops.deploy' requires approval. Proceed? [y/N]

2. The MCP Surface

If Claude is calling your tool via MCP, apcore-mcp uses the protocol's Elicitation feature. A confirmation dialog appears directly in the Claude or Cursor interface, allowing the user to click "Approve" before the AI continues.

3. The Agent-to-Agent (A2A) Surface

In an A2A workflow, the "Provider Agent" sends an input-required status back to the "Consumer Agent." The Consumer Agent then knows it must pause its task and ask its own human user for permission.


Bypassing Approval: The Trusted Context

There are scenarios where you want to bypass the gate—for example, during automated CI/CD runs or when a highly trusted system administrator is using the CLI.

apcore allows this via the Trusted Context:

  • CLI: The -y or --yes flag tells the handler to auto-approve.
  • Identity: You can configure your registry to auto-approve calls from specific identity.types (e.g., "system") while requiring them for "user" or "agent".

Conclusion: Bridging Fear and Autonomy

The path to production AI is not about making models "smarter"—it's about making our infrastructure safer. By enforcing "Human-in-the-Loop" at the protocol level, apcore gives enterprises the confidence to deploy autonomous Agents, knowing that the "Brake Pedal" is always under human control.

Next, we wrap up Volume II with "Observability 2.0: Tracing AI 'Thought Chains' with OpenTelemetry."


This is Article #16 of the **Building the AI-Perceivable World* series. Join us in building secure and governed AI architectures.*

GitHub: aiperceivable/apcore