ExamplescriptintermediateRunnablehuman-approval
Feedback: Provides strategic points where human judgement is required.
This component implements approval workflows and human-in-the-loop processes for high-risk decisions or complex judgments.
Key Facts
- Level
- intermediate • Agent Building Blocks
- Runtime
- Python • OpenAI API
- Pattern
- Human-in-the-loop approval before final action
- Interaction
- Live sandbox • Script
- Updated
- 14 March 2026
Navigate this example
Library
Browse examplesReopen the wider library to compare adjacent patterns and linked learning paths.Interaction
Run sandbox nowTry the interaction directly in this example’s guided sandbox surface.Source
Open full sourceRead the real implementation, highlighted checkpoints, and runtime requirements.MCP
Call via MCPUse the same resource inside agents, deterministic exports, and MCP setup flows.
Linked principles
7-feedback.py
python
"""
Feedback: Provides strategic points where human judgement is required.
This component implements approval workflows and human-in-the-loop processes for high-risk decisions or complex judgments.
"""
from openai import OpenAI
def get_human_approval(content: str) -> bool:
print(f"Generated content:\n{content}\n")
response = input("Approve this? (y/n): ")
return response.lower().startswith("y")
def intelligence_with_human_feedback(prompt: str) -> None:
client = OpenAI()
response = client.responses.create(model="gpt-4o", input=prompt)
draft_response = response.output_text
if get_human_approval(draft_response):
print("Final answer approved")
else:
print("Answer not approved")
if __name__ == "__main__":
intelligence_with_human_feedback("Write a short poem about technology")
Related principles
- P1delegationDesign for delegation rather than direct manipulationDesign experiences around the assignment of work, the expression of intent, the setting of constraints, and the review of results, rather than requiring users to execute each step manually.Open principle →
- P5delegationReplace implied magic with clear mental modelsThe product should help users understand what the system can do, what it is currently doing, what it cannot do, and what conditions govern its behaviour.Open principle →
- P7trustEstablish trust through inspectabilityUsers should be able to examine how a result was produced when confidence, accountability, or decision quality is important.Open principle →
- P8trustMake hand-offs, approvals, and blockers explicitWhen the system cannot proceed, the reason should be immediately visible, along with any action required from the user or another dependency.Open principle →
- P10delegationOptimise for steering, not only initiatingThe system should support users not only in starting tasks, but also in guiding, refining, reprioritising, and correcting work while it is underway.Open principle →