DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / HumanFeedbackProvider
Class hitl

HumanFeedbackProvider: Reference Guide

By DevShelfHub

Abstract base for human-feedback providers — implement to integrate Slack, email, webhook, custom UIs.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is HumanFeedbackProvider?

HumanFeedbackProvider is the extension point CrewAI Flows call when a method decorated with @human_feedback needs an operator decision. Your subclass implements an async request() (signature evolves with CrewAI releases but always receives a PendingFeedbackContext) that renders the prompt somewhere humans act, then returns the free-text or structured answer the Flow should resume with. The runtime suspends the Flow until that awaitable completes, which is why durable @persist configuration matters: without persistence the process would die mid-wait and lose routing metadata.

Good providers enforce timeouts, idempotency keys, and authentication on inbound callbacks — think Slack interactive buttons signed with your workspace secret, not an open HTTP endpoint that replays arbitrary approvals. They also propagate correlation IDs from ctx into tickets so support teams can trace which automation instance is blocked.

Keep request() non-blocking for the event loop: await Slack APIs, push slow LDAP lookups to threads, and never call time.sleep inside async providers. Pair with observability so stuck approvals surface as metrics rather than silent Flow hangs.

When to Use

Custom HITL channels.

Use Cases

  • • Slack approval bot
  • • Email approvals
  • • Custom web UI

Key Features

  • ✓ Async-friendly
  • ✓ Pluggable
  • ✓ Routes via PendingFeedbackContext

When NOT to Use

Default CLI prompt is fine.

Notes

Always persist long waits

Human responses can take hours. Without @persist the hosting process must stay up and in-memory state is fragile across deploys.

Authenticate callbacks

Treat approval tokens like webhooks: verify signatures, bind decisions to ctx ids, and reject duplicate posts.

Return concise machine-usable strings

Flows usually parse the returned text downstream. Agree on a delimiter or JSON envelope with the resuming method.

Back-pressure on shared channels

Flooding a single Slack channel with every micro-decision trains users to ignore it. Batch or route by severity.

Import

python
from crewai.flow.human_feedback import HumanFeedbackProvider

Code Examples

Minimal async provider

python
from crewai.flow.human_feedback import HumanFeedbackProvider, PendingFeedbackContext

class EchoProvider(HumanFeedbackProvider):
    async def request(self, ctx: PendingFeedbackContext) -> str:
        return f"APPROVED:{ctx.prompt[:120]}"

Slack-style stub with timeout guard

python
import asyncio
from crewai.flow.human_feedback import HumanFeedbackProvider, PendingFeedbackContext

class SlackProvider(HumanFeedbackProvider):
    async def request(self, ctx: PendingFeedbackContext) -> str:
        return await asyncio.wait_for(self._post_to_slack(ctx), timeout=3600)

    async def _post_to_slack(self, ctx: PendingFeedbackContext) -> str:
        return 'approved'

Construct once per process

python
provider = EchoProvider()
# Pass provider into Flow wiring so every @human_feedback method shares the same channel.

Common Mistakes

❌ Blocking the event loop in request()

✅ Await async I/O or run sync work in a thread.

HumanFeedbackProvider FAQ

What is HumanFeedbackProvider in CrewAI?

Abstract base for human-feedback providers — implement to integrate Slack, email, webhook, custom UIs. HumanFeedbackProvider is the extension point CrewAI Flows call when a method decorated with @human_feedback needs an operator decision. Your subclass implements an async request() (signature evolves with CrewAI releases but always receives a PendingFeedbackContext) that renders the prompt somewhere humans act, then returns the free-text or structured answer the Flow should resume with. The runtime suspends the Flow until that awaitable completes, which is why durable @persist…

Which package defines the CrewAI class HumanFeedbackProvider?

DevShelfHub maps HumanFeedbackProvider to Python module crewai.flow.human_feedback (package path crewai.flow.human_feedback in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use HumanFeedbackProvider?

Custom HITL channels.

When should I avoid using HumanFeedbackProvider?

Default CLI prompt is fine.

How do I import HumanFeedbackProvider in Python?

from crewai.flow.human_feedback import HumanFeedbackProvider

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.