Human in the loop for CrewAI.
CrewAI's human_input asks whoever is running the crew at the terminal. For crews that run on their own, give the agent a tool that asks ID verified people instead, and have its backstory require it before any decision that costs money or trust.
pip install crewai pluresHow it works
- 1
Make the tool
Decorate a function with @tool. Its docstring tells the agent when to use it.
- 2
Give it to the agent
Add it to the agent's tools and say in the backstory that refunds and similar calls always go through it.
- 3
Act on the answer
The tool returns the answer, the agreement and whether to act or escalate.
The code
Runs as is with a free pk_test_ key, which answers instantly without reaching people.
from crewai import Agent, Crew, Task
from crewai.tools import tool
from plures import Plures
plures = Plures() # reads PLURES_API_KEY
@tool("Ask verified humans")
def ask_verified_humans(question: str, options: list[str], context: str) -> str:
"""Ask ID verified people to decide a judgment call before acting on it.
Use it for refunds, a customer's tone or intent, or whether two documents match.
question: what people should decide, answerable from the context alone.
options: two to eight possible answers. context: the material to judge."""
task = plures.verify(question, options, context=context, verifiers=3, timeout=300)
r = task.get("result") or {}
if task["status"] != "completed" or r.get("answer") is None:
return "No clear answer from verified people. Escalate to the team."
verdict = "Safe to act on." if r["agreement"] >= 1 else "Not unanimous: escalate instead of acting."
return f"Verified people answered {r['label']} (agreement {r['agreement']:.0%}). {verdict}"
support = Agent(
role="Refund specialist",
goal="Resolve refund requests fairly",
backstory="You never approve or decline a refund without asking verified humans first.",
tools=[ask_verified_humans],
)
ticket = Task(
description="Customer: 'The cake showed up a day late and smashed. Amazing service, really.' Order: $64.",
expected_output="The refund decision and a short reply to the customer.",
agent=support,
)
print(Crew(agents=[support], tasks=[ticket]).kickoff())What your agent gets back
The answer, how strongly people agreed from 0 to 1, and each vote. Act on a unanimous answer; send anything less to your team.
{
"status": "completed",
"result": {
"answer": "Yes",
"label": "Yes",
"agreement": 1,
"answers": 3,
"votes": { "Yes": 3, "No": 0 }
}
}Questions
How is this different from human_input=True?
human_input asks the person running the crew, at the terminal, every time. This asks several ID verified people only when the agent decides a call needs it, and works when the crew runs unattended.
Can my own team answer instead?
Yes. Send the task with route: "team" and it goes to your team's Decisions app and Slack. The first 50 a month are free.
How do I start?
Get a free API key at plures.si. Test keys (pk_test_) answer instantly without reaching people, so you can build the whole flow first. Then send your own team up to 50 decisions a month for free, and add credit when you want ID verified people on the rest.
Other integrations
Product names and logos are trademarks of their owners, shown only to name the tools these pages are about.