mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
ded17b178c
* Remove Python-only declarative actions and rename alias kinds to C# canonical names * Address PR comments. * Address PR comments. * Reduce verbose and duplicate output from sample workflow.
ded17b178c
ยท
2026-05-28 10:16:22 +00:00
History
Human-in-Loop Workflow Sample
This sample demonstrates how to build interactive workflows that request user input during execution using the Question and RequestExternalInput actions.
What This Sample Shows
- Using
Questionto prompt for user responses - Using
RequestExternalInputto request external data - Processing user responses to drive workflow decisions
- Interactive conversation patterns
Files
workflow.yaml- The declarative workflow definitionmain.py- Python script that loads and runs the workflow with simulated user interaction
Running the Sample
-
Ensure you have the package installed:
cd python pip install -e packages/agent-framework-declarative -
Run the sample:
python main.py
How It Works
The workflow demonstrates a simple survey/questionnaire pattern:
- Greeting: Sends a welcome message
- Question 1: Asks for the user's name
- Question 2: Asks how they're feeling today
- Processing: Stores responses and provides personalized feedback
- Summary: Summarizes the collected information
The main.py script shows how to handle ExternalInputRequest to provide responses during workflow execution.
Key Concepts
ExternalInputRequest
When a human-in-loop action is executed, the workflow yields an ExternalInputRequest containing:
variable: The variable path where the response should be storedprompt: The question or prompt text for the user
The workflow runner should:
- Detect
ExternalInputRequestin the event stream - Display the prompt to the user
- Collect the response
- Resume the workflow (in a real implementation, using external loop patterns)
ExternalLoopEvent
For more complex scenarios where external processing is needed, the workflow can yield an ExternalLoopEvent that signals the runner to pause and wait for external input.