human-in-the-loop
Skill0 starsChanged 6 months agoMITView on GitHub
Gate tool execution behind human approval using asyncio.Future. Use when deploying agents that perform irreversible actions (payments, deletions, emails) and need a human review step before proceeding.
8 other projects use a version of this.
Adopted by
Most recently taken up by
- asmamest/Nexus-Skillstheir own version, first seen Nov 1, 2026
- BojanKocijan/design-forgetheir own version, first seen Oct 19, 2026
- bingyue/fde-skillstheir own version, first seen Oct 13, 2026
- BojanKocijan/bk-charterlinetheir own version, first seen Oct 13, 2026
- Sathvikar01/Agent-engineering-skillstheir own version, first seen Oct 5, 2026
- VoDaiLocz/kilo-kit-mcptheir own version, first seen Aug 21, 2026
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- VoDaiLocz/kilo-kit-mcp★ 28same name
- bingyue/fde-skills★ 5same name
- BojanKocijan/bk-charterline★ 4same name
- BojanKocijan/design-forge★ 4same name
- hajekim/agentic-design-patterns-skills★ 4same name
- Sathvikar01/Agent-engineering-skills★ 3same name
- asmamest/Nexus-Skills★ 1same name
- hajekim/agentic-design-patterns-extension★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/building-agents/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- adding-guardrailsSkill
- agent-health-timeoutSkill
- agent-permission-scopingSkill
- agent-session-isolationSkill
- agent-step-loggingSkill
- agent-supervisor-routerSkill
- agent-telemetrySkill
- async-agent-backgroundSkill
- building-agentsSkill
- building-teamsSkill
- building-toolsSkill
- calendar-scheduling-toolSkill
- callback-tracing-handlerSkill
- chain-of-thought-promptingSkill
- chat-model-configurationSkill
- code-execution-sandboxSkill
- common-agent-patternsSkill
- context-window-managementSkill
- conversation-memorySkill
- conversation-state-dbSkill
- database-query-toolSkill
- document-loadersSkill
- document-rerankingSkill
- email-notification-toolSkill
- embedding-model-ingestionSkill
- fallback-model-chainSkill
- few-shot-injectionSkill
- filesystem-toolSkill
- hybrid-searchSkill
- inspecting-streamsSkill
- integrating-with-laurenSkill
- json-schema-enforcementSkill
- llm-provider-connectionSkill
- llm-rate-limitingSkill
- long-term-vector-memorySkill
- managing-memorySkill
- migrating-to-lauren-aiSkill
- multi-agent-delegationSkill
- multi-tool-orchestrationSkill
- multi-turn-tool-stateSkill
- output-guardrailsSkill
- plan-and-execute-agentSkill
- prompt-injection-defenseSkill
- prompt-versioningSkill
- rag-pipelineSkill
- react-agent-loopSkill
- response-validation-retrySkill
- rest-api-toolSkill
- securing-agentsSkill
- semantic-cacheSkill
- streaming-response-handlerSkill
- structured-output-parsingSkill
- sub-agent-spawningSkill
- system-prompt-templatingSkill
- testing-agentsSkill
- The first 60 shown.
The file
Files
Use
codemap find "ApprovalGate"after adding the pattern to your project.
Human-in-the-Loop Approval Gate
Block a tool call until a human explicitly approves or rejects it. On timeout the gate automatically declines.
Pattern
import asyncio
from uuid import uuid4
class ApprovalGate:
"""Blocks execution until a human approves or the timeout expires."""
def __init__(self, timeout: float = 30.0):
self._pending: dict[str, asyncio.Future] = {}
self._timeout = timeout
async def request(self, approval_id: str, details: dict) -> bool:
loop = asyncio.get_event_loop()
fut: asyncio.Future[bool] = loop.create_future()
self._pending[approval_id] = fut
try:
return await asyncio.wait_for(asyncio.shield(fut), timeout=self._timeout)
except asyncio.TimeoutError:
self._pending.pop(approval_id, None)
return False
def resolve(self, approval_id: str, approved: bool) -> bool:
fut = self._pending.pop(approval_id, None)
if fut and not fut.done():
fut.set_result(approved)
return True
return FalseTool integration
Inject the gate into a tool that requires confirmation:
from uuid import uuid4
from lauren_ai._tools import tool, ToolContext
@tool()
class TransferFundsTool:
"""Transfer funds between accounts.
Args:
from_account: Source account ID.
to_account: Destination account ID.
amount: Amount in USD.
"""
def __init__(self, gate: ApprovalGate):
self._gate = gate
async def run(
self, ctx: ToolContext, from_account: str, to_account: str, amount: float
) -> dict:
approval_id = str(uuid4())
approved = await self._gate.request(
approval_id,
{"from": from_account, "to": to_account, "amount": amount},
)
if not approved:
return {"error": "Transfer declined by operator"}
# Perform the actual transfer
return {"status": "transferred", "amount": amount}Approval workflow (banking chatbot pattern)
User ──► Agent ──► TransferFundsTool ──► ApprovalGate.request()
│ (blocks, waiting)
Operator reviews ──────────────────────► gate.resolve(id, True/False)
│
◄─── tool returns result ───────┘Testing
import asyncio
async def test_approval_approved():
gate = ApprovalGate(timeout=5.0)
approval_id = "req-001"
# Schedule approval after a short delay
async def approve_after_delay():
await asyncio.sleep(0.01)
gate.resolve(approval_id, True)
asyncio.create_task(approve_after_delay())
result = await gate.request(approval_id, {"action": "delete"})
assert result is True
async def test_approval_timeout():
gate = ApprovalGate(timeout=0.05)
result = await gate.request("req-timeout", {"action": "send"})
assert result is FalseNotes
asyncio.shieldprevents the Future from being cancelled whenwait_forraisesTimeoutError, allowing safe cleanup.- Each
approval_idshould be a UUID so concurrent requests don't collide. - For multi-worker deployments, replace the in-process
Futurewith a Redis pub/sub channel or a webhook endpoint.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

