Human-in-the-Loop and Checkpoints in Microsoft Agent Framework: Approvals, Crashes and Restarts

On this page
An AI workflow that orders software licenses must not simply go ahead with 25
seats. It has to stop, ask a manager, wait for the answer, possibly
overnight, and then continue exactly where it left off. If the server crashes
or the container is redeployed in between, the approval must not get lost and
the order must not go out twice. Microsoft Agent
Framework
has two building blocks for this:
human-in-the-loop
through ctx.request_info, and durable
checkpoints.
On November 30, 2026 we built both with agent-framework-core 1.26.0
(released November 12, 2026) and then broke them on purpose: with kill -9
in the middle of an LLM call, with crashes right after an order, with time
travel to old checkpoints, and with the Azure AI Foundry host. This post
shows every step with runnable code, the output from our runs and the
measurements.
This is part 3 of our series. In part 1
we built an IT helpdesk agent with tools, DevUI, FastAPI and Docker, and in
part 2 an IT
ticket pipeline with WorkflowBuilder, executors and conditional edges.
Part 2 only announced checkpoints and approvals. Now we build them. We assume
you know executors, edges, supersteps and WorkflowContext.
Note on Azure AI Foundry: According to Microsoft Learn, the Foundry workflow designer and in-portal workflow execution are not supported after December 1, 2026. If you built workflows there, you end up with code-first workflows like the one in this post. Step 11 shows how to run exactly this workflow as a Foundry Hosted Agent.
What we build: a license approval with pause and revision
We automate the case part 2 named as an outlook: an employee requests software licenses, and above a certain amount a human has to approve. The workflow has three executors:
intake: An agent reads the free text from the helpdesk and turns it into a structuredLicenseRequestwith product, seat count and justification.approval_gate: The price comes from a price list in code, not from the LLM. Up to €100 per month the workflow approves automatically. Above that it pauses withctx.request_infoand waits for a manager. If the manager rejects with feedback, the request goes back tointake(three rounds at most).provisioning: Orders the licenses in a simulated license shop, one line inorders.jsonl, and then sends the confirmation.
Architecture of the license approval: intake, approval_gate and provisioning, the pause through request_info, the loop on rejection and, below, the chain of checkpoints in FileCheckpointStorage
Every step runs as its own process through a small command line: start, inbox, decision, resume after a crash, and history. That way we test what happens in practice: hours pass between pause and answer, and the process that handles the answer has nothing in memory except the checkpoint.
The key results from our runs up front:
| Test | Observation |
|---|---|
| Pause, answer in a new process | Works across three processes, including rejection, LLM revision and approval |
kill -9 during the LLM call | Resume repeats only this one LLM call (738 tokens); the first one (885 tokens) is kept |
kill -9 after the order | Without protection: two orders. With an idempotency check: one |
| Answering an old checkpoint again | The framework allows it and orders again. The Foundry host rejects it ("stale or forked") |
| Own types not allowed | The workflow pauses anyway, but without a checkpoint, with only a warning in the log |
Overhead of FileCheckpointStorage | 1.65 ms instead of 0.47 ms up to the pause, about 2 KB per checkpoint |
| Restart in a fresh process until answer | about 340 ms, of which about 285 ms are Python imports |
Prerequisites
- Python 3.11 or newer. We tested with Python 3.13.13 and
uv. - An LLM with an OpenAI-compatible API. We use
nvidia/nemotron-3.5-lightning-30b-a3bthrough NVIDIA Build, because an API key is all it takes. According to its signature,OpenAIChatCompletionClientfromagent-framework-openaialso acceptsazure_endpointandcredentialfor Azure OpenAI. We did not run that variant for this post. - For step 11: the
agent-framework-foundry-hostingpackage. We ran the Foundry host locally. We did not run the deployment to Azure withazd; it needs an Azure subscription and a Foundry project.
The pinned versions from our test:
| Package | Version | Released |
|---|---|---|
agent-framework-core | 1.26.0 | 2026-11-12 |
agent-framework-openai | 1.18.2 | 2026-11-12 |
agent-framework-devui | 1.0.0b261112 | 2026-11-12 |
agent-framework-foundry-hosting | 1.0.0b261112 | 2026-11-12 |
Step 1: Create an environment with pinned versions
Since 2026, providers live in their own packages. The Python upgrade
guide
lists the changes since parts 1 and 2: ChatAgent is now Agent, the start
node is passed to the constructor as WorkflowBuilder(start_executor=...),
and streaming goes through workflow.run(..., stream=True); Workflow has no
separate run_stream() in 1.26.0 anymore. Pin the whole set of packages,
since the sub-packages have their own version numbers.
Step 2: Data models for request, approval and revision
Everything that flows between executors or waits in a pause ends up in a
checkpoint later. That is why we use small Pydantic models with clear names.
Create models.py:
We learned two details only while testing. DevUI builds a form from
ApprovalDecision automatically and shows the docstring as its explanation
(step 8). And without the default approved: bool = False, it marks the
checkbox as required: the "Submit Response" button stays disabled until you
tick the box, so a rejection is impossible in the form.
Step 3: Executors with request_info and @response_handler
The actual logic goes into workflow.py. We show the file in four parts;
put together, they are exactly the file from our test.
Imports, price list and LLM client
We added the timeout after a failure: in our first runs, one LLM call hung for more than two minutes, without an error and without an answer. Without a timeout, such a call blocks the workflow indefinitely. With a timeout it fails, and you can restart the workflow from the last checkpoint.
The prices live in code on purpose. In early versions we let the LLM estimate the list price and got anything from €10.80 to €22 per seat for the same request. That is useless for an approval threshold.
Workflow step 1: intake with two handlers
An executor can have several @handler methods. The framework picks one by
message type: TicketInput goes to from_ticket, RevisionRequest to
revise. ctx.set_state stores the ticket ID in the workflow's shared
state. It is saved with every checkpoint, and provisioning reads it later
for the idempotency check.
Workflow step 2: the approval with request_info
This class holds the human-in-the-loop part. ctx.request_info(request_data=..., response_type=...) emits an event of type request_info and ends the
superstep. If there is nothing else to do, the workflow switches to
IDLE_WITH_PENDING_REQUESTS and saves a checkpoint with the open request.
The @response_handler method later receives both sides: the original
request and the answer. The framework matches them through the type
annotations of original_request and decision. So you do not have to keep
anything in instance variables, which a restart would wipe anyway.
Workflow step 3: provisioning, graph and storage
Three details in this part need an explanation:
- The
IDEMPOTENTenvironment variable only exists for our experiment in step 6. In your code, the check belongs in there permanently. allowed_checkpoint_types:FileCheckpointStoragestores your own classes with pickle and, for security reasons, only loads allowed types. A missing type leads to something unpleasant that we show in step 9.- One folder per ticket: checkpoints carry no run ID, only the workflow
name. In a shared folder,
storage.get_latest()with the workflow name therefore returns the newest checkpoint of any ticket. In our first draft, exactly that matched an approval to the wrong run.
The gate -> intake loop is allowed; workflows may contain cycles.
WorkflowBuilder caps supersteps at 100 by default (max_iterations), and
our own limit of three rounds kicks in long before that.
Step 4: Start, inbox and decision in separate processes
The app.py command line stands in for what a web app or a Teams bot would
do in production. Every command is its own process:
The core is in decide. workflow.run(checkpoint_id=..., responses=...)
restores the checkpoint and delivers the answer in a single call. The
answer is a dictionary from request ID to response object. We read the
request ID from the checkpoint's pending_request_info_events, so the process
does not need to know anything from the first run.
Let's start the first ticket. The request text is German, as it would be in our helpdesk:
The first run took 6.3 seconds, nearly all of it the LLM call. Then the
process ends. The folder checkpoints/IT-4711/ now holds three JSON files.
The checkpoint of the pause looks like this, shortened:
You can see the shared state (ticket_id), the graph hash and the open
request. The request itself is embedded as a base64 pickle. So the file is
only partly readable, and anyone with write access to the folder can inject
code that the next restore will execute. Microsoft states this explicitly in
the checkpoint documentation:
the storage is a trust boundary, never load checkpoints from untrusted
sources.
Step 5: Reject with feedback, the LLM revises the request
The manager wants only 10 seats for now. The command for that, again in a new process:
If you want to reproduce the crash test from step 6 on this ticket, do not run
this command yet. In step 6 we send exactly this rejection through crash.sh
and kill the process halfway.
The @response_handler sends a RevisionRequest back to intake, the LLM
revises the request, and the gate pauses again with 10 seats and €150 per
month. The history shows when the framework saves along the way. The output
below is from the end, after the rejection, crash, resume, approval and order
from steps 5 and 6 had all run:
The right-hand column shows which executor still has messages in flight or
which approval is open. Since version 1.13.0 the framework writes, in
addition to the checkpoints at the end of each superstep, an entry
checkpoint at the start (#1) and one whenever a response arrives (#4 and
#8). That is why #3 and #4 share the same step number. The 1.13.0
migration guide
warns about exactly this: order comes from previous_checkpoint_id and the
timestamp, not from iteration_count. All files are between 0.7 and 2.5 KB.
Step 6: Simulate a crash with kill -9
A cleanly exiting process tells you little about recovery. So we kill the
process in the middle of its work with SIGKILL, with no chance to clean up.
A small script does that:
Make it executable with chmod +x crash.sh. The delay has to be shorter than
your model's response time. Our LLM calls took 6 to 8 seconds, so 2.5 seconds
reliably hit the running call.
Crash 1: in the middle of the LLM call
The rejection from step 5 actually went like this: after 2.5 seconds, while
intake was still waiting for the LLM, we killed the process.
The manager's decision was not lost; it is stored in #4 and #5. resume
starts at #5 and runs only the interrupted superstep: one LLM call with 738
tokens. The first call with 885 tokens from the start does not run again,
and above all nobody has to repeat the approval.
Crash 2: after the order, before the checkpoint
Now the unpleasant case. The manager approves 10 seats, provisioning
writes the order and then needs 5 seconds for the confirmation. After 2
seconds we kill the process. For this test, the idempotency protection is
switched off:
The file now holds two orders for one ticket. The cause is when checkpoints
are written: at the end of a superstep. The last checkpoint (#9) contains
the message to provisioning, but not the fact that the order already went
out. On resume, the whole step runs again. So the framework guarantees "at
least once", not "exactly once".
Pause, crash and resume for ticket IT-4711 across five processes: two pauses, one crash during the LLM call, one crash after the order and the resulting duplicate order
With the protection switched on, we repeat the same thing with a second ticket:
This time there is exactly one order. In real systems, the idempotency key (here the ticket ID) belongs in the license shop's API or in a database with a unique index, not in a local file. Also keep in mind that our guard skips the confirmation mail after the restart as well. Every side effect needs its own protection, or you split it into its own executor so that a checkpoint lands in between. We cover more failure modes of agent systems in our post on high-quality AI agent systems.
A ticket below the threshold runs through without a pause:
Step 7: Time travel to an old checkpoint
Every checkpoint stays on disk, and every one can be loaded again. That is useful for debugging and what-if questions. We load the first pause (#3, 25 seats), even though the ticket was closed long ago, and approve it as the CFO:
The full checkpoint ID is the file name under checkpoints/IT-4711/; history
only shows the first eight characters. Use the ID of your own round 1 pause
checkpoint.
With protection, nothing happens. Without it, the workflow orders another 25 seats, although the request was rejected in round 1 and closed with 10 seats in round 2. The history shows two new branches, both with #3 as their parent:
Time travel: two new runs branch off checkpoint 3, with the guard nothing is ordered, without it 25 more seats are ordered, and the Foundry host rejects a repeated answer
So the checkpoint storage does not stop anyone from answering the same pause twice. If you accept approvals through a web app, mark each request ID as "answered" the first time you process it and reject every later answer. The Foundry host from step 11 already does this on its own.
Step 8: Approve in DevUI
For development and demos you do not need to build your own UI. The
DevUI
from parts 1 and 2 can now show and answer approvals. devui_app.py:
In agent-framework-devui 1.0.0b261112, the API requires a bearer token by
default. Without auth_token, serve generates a random token at startup
and writes it to the log. The web UI asks for it on first load. Through
"Configure & Run", DevUI builds a form with the fields ticket_id and
text from TicketInput. As soon as the workflow pauses, "Workflow is
waiting for your input" appears, with the form generated from
ApprovalDecision below it:
DevUI with a paused workflow: the approval request shows the product, 25 seats and 375 euros per month, with the generated form for approver, checkbox and comment below
With "approved" unticked and the comment "Bitte zuerst nur 10 Plätze." ("only
10 seats for now"), the request goes back to intake. A few seconds later,
round 2 with 10 seats and €150 shows up in the form:
DevUI after the rejection: round 2 of the approval request with 10 seats and 150 euros per month, again with an open form
The "Checkpoint Storage" selector in the top right shows that DevUI also works with checkpoints. We did not test that feature further. For production, DevUI is no replacement for an approval front end: it has no roles, no notifications and no inbox across tickets.
Step 9: Four pitfalls when resuming
What happens when something does not fit on resume? We triggered the most common errors on purpose:
Set pause_id to a pause checkpoint from your own run. The output, with the
three long warnings shortened:
| Case | Behavior in 1.26.0 | What to do |
|---|---|---|
| Own types not allowed | Not a single checkpoint, the run pauses anyway, only warnings in the log | Maintain allowed_checkpoint_types, check the pause with resolve_pause_checkpoint_id |
| Executor class renamed or edge added | WorkflowCheckpointException, nothing runs | Finish old runs with old code, version graph changes |
| Answer with the wrong type | ValueError before anything runs | Validate answers before sending (Pydantic) |
| Unknown request ID | ValueError before anything runs | Always read the request ID from the checkpoint |
| Logic inside an executor changed | No error: the hash only covers IDs, class names and edges | Decide deliberately whether old runs may continue with new logic |
The first case is the most dangerous. Since a fix that the source code
records as issue #8181, the framework already checks at save time whether a
checkpoint could be loaded again, and refuses to save it. But the run goes
on and ends with a normal IDLE_WITH_PENDING_REQUESTS. If the process exits
now, the approval is lost. That is why our app.py calls ensure_durable
after every pause: resolve_pause_checkpoint_id returns None if no saved
checkpoint contains the open request. As for the graph hash: according to
the source (_compute_graph_signature), it covers executor IDs, the module
and class name of each executor, the edges and the names of the conditions.
It does not notice a changed approval threshold.
Step 10: What checkpoints cost
We ran the workflow 40 times with an LLM stub and no network: once without
checkpoints, once with InMemoryCheckpointStorage and once with
FileCheckpointStorage on a local SSD. We measured the time up to the pause
and from the answer to the end. Every run starts with fresh executor objects.
In the two checkpointed variants we also rebuild the workflow between pause
and answer; without checkpoints, the same instance receives the answer.
Two charts: at the top the overhead per run, 0.47 milliseconds without checkpoints and 1.65 milliseconds with FileCheckpointStorage up to the pause; at the bottom the checkpoint size, which grows with the payload from 2.1 KB to 1.3 MB per file
| Storage | Up to the pause (median) | Answer to end (median) |
|---|---|---|
| No checkpoints | 0.47 ms | 0.49 ms |
InMemoryCheckpointStorage | 0.69 ms | 0.84 ms |
FileCheckpointStorage | 1.65 ms | 1.84 ms |
Next to an LLM call of 6 to 8 seconds, that does not register. The cold start costs more: a fresh Python process that loads a paused run and handles the approval took about 340 ms across five runs. About 285 ms of that were imports, 34 ms loading the checkpoint and building the graph, and 19 ms restore and execution.
Size depends almost entirely on the payload. With a short justification,
the largest checkpoint was 2.1 KB and all six of one run together 8.9 KB.
With a 1 MB document inside the message, each checkpoint grows to 1.3 MB
(pickle plus base64) and the run takes 5.3 MB, because the message sits in
several checkpoints. Large documents therefore belong in blob storage, and
only the URL travels through the workflow. For workflows with many steps, a
cleanup rule pays off as well, because FileCheckpointStorage never deletes
anything on its own.
Step 11: The same workflow as a Foundry Hosted Agent
So far we hosted the workflow ourselves, as in part 1 with FastAPI and
Docker. The alternative is Microsoft Foundry Hosted
Agents:
Microsoft runs the container, the sessions, the identity and the endpoints.
According to the documentation, the service is generally available, while
the Python package agent-framework-foundry-hosting is a prerelease. It can
host a Workflow directly, without wrapping it in an agent.
We installed the package in a second virtual environment and ran it locally:
workflow.py and models.py stay unchanged. Two rules from the
documentation matter here: the factory must return a fresh graph for every
request, and the workflow itself gets no checkpoint storage, because the host
manages it. Locally, the host writes files under ~/.agentserver/; in
Foundry it uses the Foundry State Store.
A new ticket with curl:
The pause shows up as a regular function_call named request_info, which
any OpenAI-compatible client understands. Then we killed the host with
kill -9, restarted it and sent the approval as a function_call_output:
The restart caused no trouble, and the host rejects the repeated answer.
That is the protection we had to build by hand in step 7. One pitfall cost
us some time: locally, the Foundry platform context is missing, so the host
derives the session from agent_session_id. Without that field in the
second request, it only answers "Native workflow scoped continuation
failed", and the log says "The previous response has no completed workflow
checkpoint in this trusted scope". In Foundry, the platform sets the session
itself.
The actual deployment follows the guide on Microsoft
Learn
with azd ext install azure.ai.agents, azd ai agent init, azd provision
and azd deploy. We did not run this part for this post. Check model
availability, quota and region for your Foundry project first.
| Criterion | Self-hosted (FastAPI, Docker) | Foundry Hosted Agent | Durable Extension (Azure Functions) |
|---|---|---|---|
| Checkpoints | Your own storage, e.g. files or Cosmos DB | Managed by the host (Foundry State Store) | Durable Task Scheduler |
| Duplicate answers | Lock them yourself (step 7) | Rejected ("stale or forked") | Not tested |
| Interface for approvals | Your choice | Responses API: function_call and function_call_output | HTTP and function triggers |
| Identity and scaling | Build it yourself | Own Entra identity, scaling by Foundry | Azure Functions |
| Package status (Nov 2026) | agent-framework-core stable | Service GA, Python package prerelease | agent-framework-azurefunctions 1.0.0, Python 3.13+ |
| Tested in this post | Yes | Locally yes, deployment no | No |
The Durable Extension makes sense if you already run on Azure Functions and spread long orchestrations across many workers. For most approval workflows, one of the first two options is enough.
Limits and when you need something else
- Exactly-once does not come for free. Checkpoints secure the state between steps. Anything with a side effect needs an idempotency key, no matter where you host. Microsoft says so explicitly for the Durable Extension: durable checkpointing does not make writes "exactly-once". According to the documentation, the same applies to the Foundry host.
- Pickle is a trust boundary. Make the checkpoint folder writable only
for the service. If your security model rules out pickle entirely, your
only option is a custom
CheckpointStoragewith a different serialization. - Multiple instances. A
Workflowinstance handles one run at a time; a secondrun()raises an error. Build a fresh graph per request, as the Foundry host requires anyway. - No inbox. The framework knows the open requests of a run, but not a list of every pending approval in the company. You need that as your own table or as part of your ticketing system.
- Observability. Who approved what and when belongs in an audit log and in traces. We show how to do that with OpenTelemetry in our post on Langfuse for LLM observability.
Conclusion
Human-in-the-loop and checkpoints worked in all our tests with Microsoft
Agent Framework 1.26.0. A workflow pauses with one line of code, survives
kill -9 at every point we tried, and picks up again in a new process in
about 340 milliseconds. Expensive LLM calls and, above all, human decisions
are not lost, and the overhead is about one millisecond per run.
Most of the effort sits outside the framework: making side effects idempotent, locking answers to old checkpoints, allowing your own types and checking that every pause really was saved. These are exactly the places where our tests produced duplicate orders and pauses without a saved checkpoint. If you would rather not build that yourself, the Foundry host gives you part of it out of the box.
If you want to automate approval processes or other long-running AI workflows in your company, Pondhouse Data can help, from architecture to production. Talk to us about your workflow.
Frequently asked questions
- What is human-in-the-loop in Microsoft Agent Framework?
- An executor calls ctx.request_info with a request object and the expected response type. The workflow then emits a request_info event and waits in the IDLE_WITH_PENDING_REQUESTS state. The answer comes back through workflow.run(responses=...) and lands in the method marked with @response_handler.
- How do I resume a workflow after a crash?
- Rebuild the same graph and call workflow.run(checkpoint_id=..., checkpoint_storage=...). storage.get_latest(workflow_name=...) returns the right checkpoint. If an approval is pending, pass responses as well, and the framework restores and delivers the answer in one call.
- Why does something run twice after resuming?
- Checkpoints are only written at the end of a superstep. If the process dies in the middle of a step, that whole step runs again on resume. Actions with side effects, such as orders or emails, therefore need their own idempotency key, for example the ticket ID.
- Why does saving a checkpoint fail with 'deserialization blocked'?
- FileCheckpointStorage serializes your own classes with a restricted pickle and only accepts allowed types. Add your classes as 'module:qualname' to allowed_checkpoint_types or register them with register_checkpoint_type. The run itself does not stop, so check with resolve_pause_checkpoint_id that the pause really was saved.
- Can I run a workflow with approvals on Azure AI Foundry?
- Yes. The agent-framework-foundry-hosting package serves a workflow as a Foundry Hosted Agent through ResponsesHostServer. The approval shows up as a function_call named request_info, and the answer comes back as a function_call_output. The Foundry Hosted Agents service is generally available; the Python hosting package is still a prerelease.
- How much time and storage do checkpoints cost?
- In our test with agent-framework-core 1.26.0, a run up to the pause took 1.65 instead of 0.47 milliseconds with FileCheckpointStorage, and each checkpoint was about 2 KB. A restart in a fresh process took about 340 milliseconds, almost all of it Python imports. With a 1 MB document inside the messages, one run grows to 5.3 MB of checkpoints.


