Skip to content

Add HITL workflow examples, Spanish translations, and slide plan#25

Merged
pamelafox merged 9 commits intoAzure-Samples:mainfrom
pamelafox:hitl
Mar 3, 2026
Merged

Add HITL workflow examples, Spanish translations, and slide plan#25
pamelafox merged 9 commits intoAzure-Samples:mainfrom
pamelafox:hitl

Conversation

@pamelafox
Copy link
Copy Markdown
Contributor

@pamelafox pamelafox commented Mar 3, 2026

Summary

Adds new Human-in-the-Loop (HITL) example files for the Microsoft Agent Framework, along with Spanish translations and README updates. These examples support the "Adding a human-in-the-loop to workflows" presentation (Session 6 of the Python + Agents series).

Based off this plan:
https://gist.github.com/pamelafox/e2c01f0a331b14a309a59063db59855e

New Example Files

Tool Approval

File Description
agent_tool_approval.py Standalone agent with @tool(approval_mode="always_require") — no workflow needed
workflow_hitl_tool_approval.py Email agent workflow with tool approval for send/schedule operations

Requests & Responses

File Description
workflow_hitl_requests.py Simple "always ask" HITL chat using ctx.request_info() and @response_handler
workflow_hitl_requests_structured.py Trip planner with structured outputs (PlannerOutput) — agent decides when to ask vs. finish

Checkpoints & Resuming

File Description
workflow_hitl_checkpoint.py Content review with FileCheckpointStorage — exit process and resume from checkpoint
workflow_hitl_checkpoint_pg.py Same workflow with custom PostgresCheckpointStorage backend

Handoff with HITL

File Description
workflow_hitl_handoff.py Interactive handoff (no autonomous mode) — pauses for user input via HandoffAgentUserRequest

Removed Examples

  • workflow_hitl_handoff_approval.py — Handoff + tool approval combined. Removed due to framework bug (microsoft/agent-framework#4411).
  • workflow_hitl_magentic.py — Magentic orchestration with plan review. Removed due to instability; not referenced from slides.
  • workflow_magenticone.py — Superseded by the above (also removed).

Other Changes

  • 7 Spanish translations in examples/spanish/ following AGENTS.md conventions (LATAM Spanish, tuteo)
  • README.md and examples/spanish/README.md updated with all new entries
  • .gitignore updated to exclude examples/checkpoints/

Key Patterns Demonstrated

  • @tool(approval_mode="always_require") with standalone Agent and in workflows
  • ctx.request_info() / @response_handler for custom HITL request/response cycles
  • FileCheckpointStorage + workflow.run(checkpoint_id=...) for durable resume
  • Custom CheckpointStorage protocol implementation (PostgreSQL)
  • HandoffBuilder without .with_autonomous_mode() for interactive multi-agent routing

New example files:
- agent_tool_approval.py: Standalone agent with tool approval
- workflow_hitl_requests.py: Simple always-ask HITL chat
- workflow_hitl_requests_structured.py: Trip planner with structured outputs
- workflow_hitl_tool_approval.py: Email agent workflow with tool approval
- workflow_hitl_checkpoint.py: Content review with FileCheckpointStorage
- workflow_hitl_checkpoint_pg.py: Custom PostgresCheckpointStorage backend
- workflow_hitl_handoff.py: Interactive handoff (no autonomous mode)
- workflow_hitl_handoff_approval.py: Handoff + tool approval combined
- workflow_hitl_magentic.py: Magentic plan review

Changes:
- Renamed workflow_hitl_handoff.py -> workflow_hitl_handoff_approval.py
- Created new simpler workflow_hitl_handoff.py (user input only)
- Removed workflow_magenticone.py (not covered in presentation)
- Added all 9 Spanish translations
- Updated both README.md files with new examples
- Updated plan.md with finalized slide content and speaker notes
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Human-in-the-Loop (HITL) workflow/agent examples (tool approval, request/response loops, checkpoints/resume, handoff, Magentic plan review), plus Spanish translations and presentation planning materials to support the Session 6 “Adding a human-in-the-loop to workflows” content.

Changes:

  • Added multiple new HITL Python examples (and Spanish equivalents) covering tool approval, request/response patterns, checkpointing (file + Postgres), handoff, and Magentic plan review.
  • Updated READMEs and .gitignore to document examples and ignore checkpoint artifacts.
  • Added slide plan / prior-session ASCII exports and introduced a reusable GitHub “pptx-from-template” skill.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
plan.md Slide plan/outline for the HITL workflows session
first_workflows.md ASCII export of prior “First workflows” slide deck
advanced_workflows.md ASCII export of prior “Advanced workflows” slide deck
examples/workflow_magenticone.py Removed MagenticOne example (superseded/unstable per PR description)
examples/agent_tool_approval.py New standalone agent example demonstrating tool approval
examples/workflow_hitl_tool_approval.py New workflow example demonstrating tool approval loop
examples/workflow_hitl_requests.py New “always ask” request/response HITL workflow
examples/workflow_hitl_requests_structured.py New structured-output HITL workflow where agent decides ask vs finish
examples/workflow_hitl_checkpoint.py New file-based checkpoint + HITL resume example
examples/workflow_hitl_checkpoint_pg.py New Postgres-backed checkpoint storage + resume example
examples/workflow_hitl_handoff.py New interactive handoff example (no autonomous mode)
examples/workflow_hitl_magentic.py New Magentic plan-review HITL example
examples/spanish/README.md Spanish README updated with new entries
examples/spanish/agent_tool_approval.py Spanish translation of tool approval agent example
examples/spanish/workflow_hitl_tool_approval.py Spanish translation of tool approval workflow example
examples/spanish/workflow_hitl_requests.py Spanish translation of always-ask HITL workflow
examples/spanish/workflow_hitl_requests_structured.py Spanish translation of structured HITL workflow
examples/spanish/workflow_hitl_checkpoint.py Spanish translation of checkpoint HITL example
examples/spanish/workflow_hitl_checkpoint_pg.py Spanish translation of Postgres checkpoint HITL example
examples/spanish/workflow_hitl_handoff.py Spanish translation of interactive handoff example
examples/spanish/workflow_hitl_magentic.py Spanish translation of Magentic plan-review HITL example
README.md Root README updated to list new HITL examples
.gitignore Ignore workflow checkpoint directory under examples/
.devcontainer/devcontainer.json Added PostgreSQL VS Code extension
.github/skills/pptx-from-template/pptx_from_template.py Helper script for generating PPTX from a template
.github/skills/pptx-from-template/SKILL.md Documentation for the PPTX template skill
Comments suppressed due to low confidence (1)

examples/spanish/workflow_hitl_tool_approval.py:221

  • The HITL yes/no prompt uses (y/n) here, but other Spanish HITL examples in this repo use bilingual control words and Spanish yes/no (s/n). Consider switching to (s/n) (or accepting both) to match the repo’s Spanish HITL convention and reduce user confusion.
            approval = input("   ¿Aprobar/Approve? (y/n): ").strip().lower()
            approved = approval == "y"
            print(f"   {'✅ Aprobado' if approved else '❌ Rechazado'}\n")
            responses[request_info_event.request_id] = data.to_function_approval_response(approved=approved)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/workflow_hitl_checkpoint_pg.py Outdated
Comment thread examples/workflow_hitl_tool_approval.py Outdated
Comment thread examples/workflow_hitl_requests.py Outdated
Comment thread examples/workflow_hitl_requests_structured.py Outdated
Comment thread examples/spanish/workflow_hitl_handoff.py Outdated
Comment thread plan.md Outdated
Comment thread plan.md Outdated
Comment thread advanced_workflows.md Outdated
Comment thread examples/workflow_hitl_requests_structured.py Outdated
Comment thread examples/workflow_hitl_magentic.py Outdated
Comment thread examples/spanish/workflow_hitl_handoff.py Outdated
@madebygps
Copy link
Copy Markdown
Collaborator

2 comments and LGTM

- Fix docstring in workflow_hitl_tool_approval.py to match implementation
- Replace json.dumps with Jsonb adapter in workflow_hitl_checkpoint_pg.py
- Move WorkflowCheckpoint to public import path
- Translate tool docstrings to Spanish in spanish/ examples
- Translate 'goodbye' termination to Spanish in workflow_hitl_handoff.py
- Fix run command filename in workflow_hitl_requests.py
- Remove misleading 'exit' from prompts in workflow_hitl_requests_structured.py
- Update AGENTS.md to clarify @tool docstring translation rule
@pamelafox pamelafox merged commit 76a672c into Azure-Samples:main Mar 3, 2026
@pamelafox pamelafox deleted the hitl branch March 3, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants