DS DevShelfHub Projects · AI tools
Tutorials/ CrewAI/ Human-in-the-Loop · API Reference →
HITL Page 17 of 29

CrewAI Human-in-the-Loop: Approvals for Risky Agent Steps

By DevShelfHub

CrewAI ships three HITL approaches. Pick the one that matches how your reviewers actually work.

Series progress17 / 29
CrewAI hitl tutorial — CrewAI Human-in-the-Loop: Approvals for Risky Agent Steps

1. CLI Human Input

The simplest gate. Set human_input=True on a Task and the runtime prompts the operator after the agent produces a draft. Good for one-off scripts and notebook demos.

python
Task(
    description="Draft a press release",
    expected_output="200-word draft",
    agent=writer,
    human_input=True,
)

2. Webhook-Based HITL

For async approvals (Slack/email/web), suspend the flow and resume on webhook callback. Custom providers receive a PendingFeedbackContext in request() with the prompt and routing metadata. Payloads are HMAC-signed; always verify on receipt.

For short operator questions inside a Flow (picklist values, confirmation strings), Flow.ask() blocks with a timeout until an input provider answers — lighter than @human_feedback gates that persist multi-hour reviews.

python
from crewai.flow.human_feedback import HumanFeedbackProvider

class SlackProvider(HumanFeedbackProvider):
    def __init__(self, channel): self.channel = channel
    async def request(self, ctx):
        msg = await slack.post(self.channel, ctx.prompt)
        return await slack.wait_for_reply(msg.ts, timeout=86400)

3. Flow-Level Review Points

Use @human_feedback in a Flow to suspend execution at a checkpoint. Pair with @persist so state survives long waits.

python
@persist()
class ReviewFlow(Flow[State]):
    @start()
    def draft(self): ...

    @human_feedback
    def review(self, draft):
        # suspends until provider returns
        return draft

Choosing an Approach

  • →CLI: developer scripts, demos.
  • →Webhook: reviewers in Slack/email; async approvals.
  • →Flow-level: structured workflows with multiple gates and audit trails (best with CrewAI AMP).

Content Approval Workflow Pattern

Research → draft → @human_feedback review → @router(approved|rejected) → either publish (approved) or revise (rejected). Persist state so reviewers can take their time. Track ticket status in the flow state for SLA dashboards.

Notes

Humans need SLAs too

Paused crews hold workers, sockets, and GPU budgets open. Set approval timeouts, escalation paths, and idempotent resume tokens so a stuck reviewer does not deadlock production traffic.

Webhooks should be signed and replay-safe

Treat approval endpoints like payment callbacks: verify signatures, deduplicate delivery IDs, and persist decisions before acknowledging so double posts cannot double-apply actions.

CLI prompts do not scale to teams

Interactive pauses are great for local debugging but brittle in CI or remote shells. Mirror the same gates behind HTTP for staging and production operators.

Record why a human said no

Rejection reasons become training data for prompts and guardrails later. Capture structured rationale alongside the resume payload instead of only logging free text to stdout.

CrewAI human-in-the-loop FAQ

Why add human approvals to CrewAI workflows?

Humans catch policy edge cases, brand risk, and data leaks that automation misses. Approvals are cheapest insurance before customer-facing actions.

What is a webhook approval gate?

A gate pauses execution until an external system approves or rejects a payload, usually over HTTPS with signed callbacks so only your operator console can resume the Flow.

How does human_feedback work in CrewAI Flows?

human_feedback decorators mark steps that require operator input or scoring before downstream nodes run, which pairs well with persisted Flow state.

Can HITL patterns slow down my CrewAI app?

Yes, because they wait on people. Design short approval queues, auto-expire stale requests, and batch low-risk decisions so humans only see exceptions.

Where do CLI human inputs fit?

CLI inputs are great for local development and demos. Production should move to authenticated webhooks or internal tools with audit trails.

See also: DevShelfHub's CrewAI tool review for a product-level comparison, pricing notes, and links back into this tutorial series.

Quick jump: API Reference