Files
wehub-resource-sync db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:25 +08:00
..

Human-in-the-Loop in a Sub-Workflow (Durable Task Worker)

This sample combines workflow composition (11_subworkflow) with human-in-the-loop (09_workflow_hitl): the HITL request_info pause lives inside an inner workflow that an outer workflow embeds via WorkflowExecutor.

On the durable host the inner workflow runs as its own child orchestration, so its pending request is recorded on the child instance. The parent records the child instance id in its custom status, which lets the client discover the nested request behind a single top-level addressing surface.

Key Concepts Demonstrated

  • A HITL pause (ctx.request_info / @response_handler) inside a sub-workflow.
  • DurableAIAgentWorker.configure_workflow(outer_workflow) registers a durable orchestration for each workflow:
    • dafx-moderation_pipeline — the outer workflow.
    • dafx-human_review — the inner (HITL) workflow, run as a child orchestration.
  • Qualified request ids: the nested request surfaces to the client with a qualified id (review_sub~0~{requestId}). The client posts the response against the top-level instance id, and the host routes it to the owning child orchestration — so the caller never has to discover child instance ids.

Composition Layout

moderation_pipeline (outer)
  intake (executor)
    -> review_sub = WorkflowExecutor(human_review)
         review_gate (executor: request_info -> response_handler)
    -> publish (executor)

Environment Setup

See the README.md in the parent directory for environment setup.

This sample uses no AI agents, so no model credentials are required. It only needs a Durable Task Scheduler. For local development, start the emulator (defaults to http://localhost:8080):

docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest

Running the Sample

Start the worker in one terminal:

cd samples/04-hosting/durabletask/12_subworkflow_hitl
python worker.py

In a second terminal, run the client:

python client.py

Each case flows: intakereview_sub (child orchestration pauses at review_gate) → client responds to the qualified request → review_gate resumes → inner decision forwarded to publish → final output.