How to Build Human-in-the-Loop Plan-and-Execute AI Agents with Explicit User Approval Using LangGraph and Streamlit
By Amr Abdeldaym, Founder of Thiqa Flow
In the evolving world of AI automation, integrating human oversight into AI workflows is paramount to ensure reliability, trust, and efficiency. This tutorial reveals how to design and deploy a human-in-the-loop AI agent for travel booking that treats the user as an active collaborator rather than a passive observer. Leveraging the power of LangGraph for agent orchestration and Streamlit for the interactive user interface, we can create an AI system where the agent generates a transparent plan, pauses for explicit user approval, and only afterward proceeds to execute actions. This architecture enhances business efficiency by ensuring that AI-driven decisions align with human intent, reducing errors and increasing user confidence.
The Challenge of Autonomous AI Agents
Autonomous AI systems often operate in opaque ways, making decisions without user visibility or consent. This can lead to:
- Unintended consequences due to misunderstood AI reasoning
- Lack of user trust and reduced acceptability
- Difficulty in correcting the AI’s course or intentions before costly actions occur
Introducing human approval as a deliberate checkpoint transforms these challenges into an opportunity for collaboration, accountability, and control.
Step-by-Step Overview: Building the Travel Booking Agent
| Stage | Description | Outcome |
|---|---|---|
| 1. Planning with LLM | The AI drafts a structured travel plan using OpenAI GPT-4, generating detailed tool-calls like flight search, hotel search, and itinerary drafting. | A clear JSON-based travel plan, explicitly outlining intended actions. |
| 2. Pause for Approval | The plan is presented to the user via a Streamlit interface for review, editing, or rejection before any execution happens. | User gains control; the AI awaits an explicit “Approve” decision. |
| 3. Controlled Execution | Only upon user approval, the agent calls external tools (flight/hotel search & itinerary) to fulfill the travel plan. | Safe and trustworthy execution aligned with human oversight. |
Implementing the Agent Logic with LangGraph
LangGraph provides a robust framework for orchestrating agent workflows by defining distinct states and transitions. The travel agent’s lifecycle comprises:
- Planning Node: Uses OpenAI’s GPT model to create a travel plan adhering to a strict JSON schema.
- Approval Node: Interrupts the workflow, exposing the proposed plan to the user through an interactive interface.
- Execution Node: Runs toolkit simulations only after explicit user authorization, preventing automatic and uncontrolled actions.
By defining strict schemas and interrupt points, the workflow becomes more auditable, trackable, and collaborative. This pattern ensures that AI doesn’t “act for us” but rather “thinks with us.”
Why Streamlit Enhances Business Efficiency in Human-in-the-Loop AI
Integrating Streamlit empowers end-users with an approachable interface to directly interact with the AI agent’s decision-making:
- Live Editing: Users can modify the JSON travel plan, improving personalization and ensuring relevance.
- Explicit Approval: Clear “Approve” or “Reject” options put users in control.
- State Persistence: Threaded sessions maintain continuity, ideal for business scenarios where multi-turn conversation integrity is essential.
This human-in-the-loop paradigm reduces wasted effort, avoids premature automation errors, and enhances user satisfaction — all key drivers of optimized AI automation in operational settings.
Summary Table: Benefits of Human-in-the-Loop Plan-and-Execute AI Agents
| Aspect | Benefit | Impact on Business Efficiency |
|---|---|---|
| Transparency | Agent’s reasoning visible before actions | Reduces costly errors and misaligned automation |
| User Control | Explicit approval/rejection before execution | Improves trust and reduces rework |
| Collaboration | Humans and AI as teammates | Boosts adoption and operational agility |
| Modularity | Clear separation of planning and execution | Enables flexible integration with existing systems |
Conclusion: A New Paradigm for Trustworthy AI Automation
Building human-in-the-loop AI agents through explicit plan-and-execute workflows transforms how businesses implement automation. By combining LangGraph’s interrupt-driven orchestration with Streamlit’s interactive frontend, this approach prevents premature, opaque AI actions and enshrines human judgment as a core control lever.
This methodology is essential for any organization aiming to deploy AI automation not just faster, but safer, more accountable, and aligned with real-world business needs. The framework scales far beyond travel booking — applicable to healthcare, finance, legal, and any domain where decisions impact people and resources meaningfully.
To explore the full project details, see the original tutorial.
Looking for custom AI automation for your business? Connect with me at https://amr-abdeldaym.netlify.app/