Human approval workflows help make sure AI decisions are checked by people before final use. This keeps results safe and trustworthy.
Human approval workflows in Agentic Ai
workflow = HumanApprovalWorkflow(
ai_model=model,
approval_condition=condition_function,
human_reviewer=reviewer_function
)
result = workflow.run(input_data)HumanApprovalWorkflow connects AI output with human checks.
The approval_condition decides when human review is needed.
workflow = HumanApprovalWorkflow(
ai_model=my_model,
approval_condition=lambda output: output['confidence'] < 0.8,
human_reviewer=ask_human
)
result = workflow.run(data)def always_approve(output): return True workflow = HumanApprovalWorkflow( ai_model=my_model, approval_condition=always_approve, human_reviewer=ask_human ) result = workflow.run(data)
This program creates a simple AI model that outputs a prediction with confidence. If confidence is below 0.9, it asks a human to approve. The human approves only if confidence is at least 0.5. The program tests three cases with different confidence values.
class HumanApprovalWorkflow: def __init__(self, ai_model, approval_condition, human_reviewer): self.ai_model = ai_model self.approval_condition = approval_condition self.human_reviewer = human_reviewer def run(self, input_data): ai_output = self.ai_model(input_data) if self.approval_condition(ai_output): print('AI output needs human approval.') approved = self.human_reviewer(ai_output) if approved: print('Human approved the AI output.') return ai_output else: print('Human rejected the AI output.') return None else: print('AI output auto-approved.') return ai_output def simple_ai_model(data): # Simulate AI output with confidence return {'prediction': 'Accept', 'confidence': data} def human_review(output): # Simulate human approval if confidence >= 0.5 print(f"Human reviewing output with confidence {output['confidence']}") return output['confidence'] >= 0.5 workflow = HumanApprovalWorkflow( ai_model=simple_ai_model, approval_condition=lambda out: out['confidence'] < 0.9, human_reviewer=human_review ) print('Test with confidence 0.95:') result1 = workflow.run(0.95) print('Result:', result1) print('\nTest with confidence 0.7:') result2 = workflow.run(0.7) print('Result:', result2) print('\nTest with confidence 0.4:') result3 = workflow.run(0.4) print('Result:', result3)
Human approval adds time but improves safety and trust.
Design clear conditions to avoid too many or too few human checks.
Keep human reviewers informed and trained for consistent decisions.
Human approval workflows combine AI with people to check important decisions.
They help catch mistakes and meet rules for sensitive tasks.
Use simple conditions to decide when to ask humans for approval.
