AI agents can automate many tasks, but not every decision should happen without human involvement.
A long-running agent may analyze documents, update records, approve requests, send notifications, or interact with external systems. Some of these actions can have real business consequences. In such cases, allowing the agent to make the final decision automatically can create unnecessary risk.
A better approach is to pause the workflow at important decision points and ask a human to review the proposed action.
This is commonly called human-in-the-loop.
In this article, we will see how to design human approval into a long-running agent workflow in C#, how approval state should be handled, and what developers should consider when building this pattern for production applications.
What Is Human Approval in an AI Agent?
Human approval means that the agent can perform analysis and prepare an action, but a person must approve that action before the workflow continues.
A simple workflow might look like this:
User Request
|
v
AI Agent
|
v
Analyze Information
|
v
Prepare Action
|
v
Human Approval
|
+---- Reject ----> End
|
+---- Approve ---> Continue
|
v
Execute ActionThe important point is that the human is not necessarily involved in every step.
The agent can still perform routine work automatically. Human involvement is added only where a decision requires review.
For example, an agent could:
Read a customer request.
Analyze the request.
Prepare a response.
Determine that a refund may be required.
Pause for approval.
Continue only after an authorized employee approves the refund.
This gives the agent automation while keeping a human responsible for sensitive decisions.
Why Long-Running Agents Need Approval Workflows
Human approval becomes more important when an agent can run for an extended period.
Consider an employee onboarding agent:
Read Employee Information
|
v
Validate Documents
|
v
Create Account Request
|
v
Human Approval
|
v
Create Accounts
|
v
Send Welcome NotificationThe first three steps might be completely automated.
Creating accounts, however, may require authorization.
If the agent reaches the approval step and the application process is restarted, the workflow should not forget that it was waiting for a decision.
The state needs to represent something like:
Workflow Status: WaitingForApproval
Approval Status: PendingThe workflow can then continue later without starting the entire operation again.
Representing Approval State in C#
A simple approval model can be represented with an enum:
public enum ApprovalStatus
{
Pending,
Approved,
Rejected
}The workflow state can then contain the approval information:
public sealed class ApprovalState
{
public string WorkflowId { get; set; } = string.Empty;
public ApprovalStatus Status { get; set; }
public string? ApprovedBy { get; set; }
public DateTimeOffset? DecisionTime { get; set; }
public string? Reason { get; set; }
}This state provides enough information to understand what happened.
For example:
WorkflowId: WF-1024
Status: Approved
ApprovedBy: employee-123
DecisionTime: 2026-09-25T10:30:00ZIn a real application, the workflow state would normally be persisted rather than kept only in application memory.
Separating Agent Decisions From Human Decisions
One of the most important design principles is to clearly separate what the agent decides from what the human approves.
For example:
Agent:
"Refund of $750 is recommended because the order
matches the refund policy."
Human:
"Approve"
System:
"Execute refund."The agent recommends an action.
The human authorizes the action.
The application executes it.
This separation makes the workflow easier to understand and audit.
A C# model could represent the proposed action like this:
public sealed class ProposedAction
{
public string ActionId { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public decimal Amount { get; set; }
public string Reason { get; set; } = string.Empty;
public ApprovalStatus ApprovalStatus { get; set; }
}The agent can populate the proposal, while the approval process controls whether the action can actually execute.
Building the Workflow Around an Approval Point
A long-running workflow can be structured into separate steps:
public async Task ProcessRequestAsync(
Request request,
CancellationToken cancellationToken)
{
var analysis = await AnalyzeRequestAsync(
request,
cancellationToken);
var action = await CreateProposalAsync(
analysis,
cancellationToken);
await SaveProposalAsync(
action,
cancellationToken);
// Workflow pauses here until approval.
if (action.ApprovalStatus != ApprovalStatus.Approved)
{
return;
}
await ExecuteActionAsync(
action,
cancellationToken);
}The important part is not the if statement itself.
The important part is that the approval becomes part of the workflow state.
A durable workflow can stop after creating the proposal and continue after an approval event is received.
Waiting for Human Input
A common mistake is to keep the application process running while waiting for someone to approve an action.
For example:
while (!approved)
{
await Task.Delay(TimeSpan.FromMinutes(1));
}This approach is generally not suitable for long-running workflows.
It keeps a process alive simply to wait for an external decision.
A better design is event-driven:
Agent
|
v
Create Approval Request
|
v
Persist Workflow State
|
v
Wait
|
| Approval Event
v
Resume Workflow
|
v
Execute ActionThe workflow does not need to continuously poll for approval.
Instead, the approval system can generate an event when the human makes a decision.
Approval Events in C#
You can represent an approval decision as a domain event:
public sealed class ApprovalDecision
{
public string WorkflowId { get; init; } = string.Empty;
public ApprovalStatus Status { get; init; }
public string ApproverId { get; init; } = string.Empty;
public string? Reason { get; init; }
}When the user approves the request, the application can process the event:
public async Task HandleApprovalAsync(
ApprovalDecision decision,
CancellationToken cancellationToken)
{
var workflow = await workflowStore.GetAsync(
decision.WorkflowId,
cancellationToken);
if (workflow is null)
{
throw new InvalidOperationException(
"Workflow was not found.");
}
workflow.ApprovalStatus = decision.Status;
workflow.ApproverId = decision.ApproverId;
workflow.ApprovalReason = decision.Reason;
await workflowStore.SaveAsync(
workflow,
cancellationToken);
}
Join the conversation! Your thoughts help the community grow.