Human in the Loop
1. Overview
The Ask Human in Chat Interface tool enables Human-in-the-Loop (HITL) workflows in StackAI.

It allows an AI workflow to pause execution, request input from a human in the Chat Assistant interface, and then resume execution once the user responds.
This allows you to build hybrid AI workflows where automation handles most of the work but defers to human judgment at critical decision points.
Common use cases include:
Confirming actions before executing high-impact, long tasks
Clarifying ambiguous user requests
Selecting between multiple possible options
Collecting information that the AI cannot infer
Example:
“Running this analysis across the full dataset may take several minutes. Would you like me to proceed, or should I limit the analysis to the most recent records?”
2. How It Works
Ask Human in Chat Interface Workflow:
Tool Invocation: LLM calls the tool for human input.
Pause Execution: workflow pauses as the need for user input is identified.
User Interaction: The question appears in the Chat UI.
User Response: The user submits an answer through the chat.
Resume Execution: Workflow resumes with user's input.
Optimize performance by equipping an LLM node with the Ask Human tool in a chat interface instead of using it as a separate action. Refer to this guide for instructions on adding tools to LLMs.

⚠️ Important: This tool only works inside the Chat Assistant interface. It does not function when workflows are triggered via API or used in Form mode, since it relies on the interactive chat UI to collect responses.

3. Configuration
Input Parameters
These parameters can either be:
Provided directly by the user, or
Dynamically set by the LLM when invoking the tool from the LLM node, just like with any other tool in a StackAI workflow.
Allowing the LLM to control these fields enables more flexible and adaptive workflows, while specifying them explicitly can enforce more deterministic behavior when required.


question
string
Yes
The question presented to the human user. It should be clear and actionable.
context
any
No
Optional context to help the user understand the situation or decision.
response_type
string
No
Determines the UI input type. Options: "text", "approval", "choice". Default is "text".
choices
array
No
List of selectable options. Only used when response_type is "choice".
3.1. Response Types
Set response_type to control what the user sees in chat.
Approval ("approval")
"approval")Use this for a simple yes/no confirmation step.

Choice ("choice")
"choice")Use this when the user should pick from a predefined list.
Set choices when using "choice".

Text ("text", default)
"text", default)Use this when you need free-form input from the user.

4. Common Use Cases
Approval Gates
Pause before performing sensitive or high-impact actions and ask the user for confirmation.
“I'm about to update 47 customer records with the new pricing. Proceed?”
Clarification Requests
Resolve ambiguity when multiple interpretations are possible.
“I found three contacts named John Smith. Which one do you mean?”
Data Collection
Gather information that the AI cannot determine automatically.
“What budget range should I use for this proposal?”
Human Review
Allow a human to review AI-generated content before executing an action.
“Here's the draft email I've prepared. Should I send it as is?”
Routing Decisions
Let a human select the next step in a workflow when multiple valid paths exist.
“This support ticket could be handled as a refund, replacement, or escalation. Which approach should we take?”
5. Best Practices
Guide the LLM on When to Request Human Input
Your LLM instructions should clearly define when human input is required. Guide the agent on how frequently it should intervene based on how critical confirmation or human judgment is for the workflow and the expected user behavior.
Use HITL sparingly for routine tasks, but require it for high-impact, irreversible, or ambiguous actions.
Example instruction:
“Before sending emails or updating databases affecting more than 10 records, ask the user for approval using the Ask Human in Chat Interface tool.”
Prefer Approvals or Choices Over Free-Text Input
Whenever possible, use approval or choice response types instead of text. Even when the parameters are controlled by the LLM, guide the agent to prefer these options.
Structured responses are faster for users and reduce friction in the workflow. In many cases, users prefer quick decisions (clicking a button or selecting an option) rather than typing responses.
Using predefined options also helps:
reduce ambiguity
avoid input errors
keep workflows moving quickly
Reserve text responses for situations where the user truly needs to provide new or open-ended information.
Choose OpenAI
OpenAI's GPT models consistently provide superior performance and results in various applications. We recommend selecting them when using Ask Human in the Chat Interface.
Last updated
Was this helpful?

