In healthcare and life sciences, AI brokers assist organizations course of scientific information, submit regulatory filings, automate medical coding, and speed up drug improvement and commercialization. Nevertheless, the delicate nature of healthcare information and regulatory necessities like Good Apply (GxP) compliance require human oversight at key resolution factors. That is the place human-in-the-loop (HITL) constructs change into important. On this submit, you’ll be taught 4 sensible approaches to implementing human-in-the-loop constructs utilizing AWS companies.
Why human-in-the-loop issues in healthcare
Healthcare and life sciences organizations face distinctive challenges when deploying AI brokers:
Regulatory compliance – GxP rules require human oversight for delicate operations. For instance, deleting affected person information or modifying scientific trial protocols can’t proceed with out documented authorization.
Affected person security – Medical selections affecting affected person care should have scientific validation earlier than execution.
Audit necessities – Healthcare techniques want full traceability of who accepted what actions and when.
Knowledge sensitivity – Protected Well being Info (PHI) requires specific authorization earlier than entry or modification.
HITL constructs present the mandatory management factors whereas sustaining the effectivity good points of agentic automation to fulfill these necessities.
Resolution overview
We current 4 complementary approaches to implementing HITL in agentic workflows. Every workflow is fitted to completely different situations and threat profiles as described in our information to constructing AI brokers in GxP Environments. We construct these patterns utilizing the Strands Brokers framework, Amazon Bedrock AgentCore Runtime, and the Mannequin Context Protocol (MCP), with code examples you could adapt on your personal use instances.
- Agentic Loop Interrupt (Agent Framework Hook System) – We use the Strands Agent Framework Hooks to implement the human-in-the-loop coverage. With the hooks, we are able to intercept software calls earlier than their execution.
- Software Context Interrupt – The human-in-the-loop approval logic can be applied inside the software logic immediately for fine-grained, tool-specific management and suppleness. The session context can be utilized for customized approval logic.
- Distant Software Interrupt (AWS Step Features) – In some instances, one would possibly need to ship an approval request to a 3rd celebration system or individual asynchronously. We display this sample by sending a notification to an exterior approver utilizing Amazon Easy Notification Service (Amazon SNS). The agent session continues with out blocking whereas approval proceeds within the background.
- MCP Elicitation – The MCP protocol just lately launched elicitation, which is utilized by servers to request extra data from customers by way of the shopper throughout interactions. The MCP’s native elicitation protocol permits for real-time, interactive approval utilizing server-sent occasions (SSE) for stateful, two-way communication.
Structure
The answer structure makes use of the Strands Brokers Framework for agent lifecycle administration and interrupt dealing with, deployed on Amazon Bedrock AgentCore Runtime for serverless scalability and session isolation. AWS Step Features orchestrates asynchronous approval workflows with Amazon SNS, whereas MCP servers expose instruments to the agent by way of the MCP—additionally deployed on AgentCore Runtime.
Implementation particulars
All of the code for these structure patterns is obtainable publicly within the GitHub repository.
Every of the next strategies demonstrates a self-contained method. The agent deploys on Amazon Bedrock AgentCore Runtime with entry to healthcare instruments at completely different sensitivity ranges. Low-risk operations, like wanting up a affected person’s title, execute with out approval, whereas high-risk actions, like retrieving vitals or medical situations, require human authorization. Operations reminiscent of affected person discharge require exterior supervisor approval by way of e-mail notification.
Methodology 1: Agentic loop hook native software interrupt
The Strands Agent Framework supplies a hook system that intercepts software calls earlier than execution on the agent loop stage. This enforces a blanket HITL coverage throughout delicate instruments with out modifying the instruments themselves.
A HookProvider registers a callback on BeforeToolCallEvent. When a delicate software is invoked, the hook fires an interrupt, pausing the agent loop till the human responds. The person can reply with “y” (approve as soon as), “n” (deny), or “t” (belief—approve this software for the remainder of the session):
class ApprovalHook(HookProvider):
SENSITIVE_TOOLS = [“get_patient_condition”, “get_patient_vitals”]
def register_hooks(self, registry: HookRegistry, **kwargs: Any) -> None:
registry.add_callback(BeforeToolCallEvent, self.approve)
def approve(self, occasion: BeforeToolCallEvent) -> None:
tool_name = occasion.tool_use[“name”]
if tool_name not in self.SENSITIVE_TOOLS:
return
# Skip if person beforehand selected “belief all the time” for this software
approval_key = f”{tool_name}-approval”
if occasion.agent.state.get(approval_key) == “t”:
return
approval = occasion.interrupt(
approval_key,
cause={“cause”: f”Authorize {tool_name} with args: {occasion.tool_use.get(‘enter’, {})}”},
)
if approval.decrease() not in [“y”, “yes”, “t”]:
occasion.cancel_tool = f”Person denied permission to run {tool_name}”
return
if approval.decrease() == “t”:
occasion.agent.state.set(approval_key, “t”) # belief software for the remainder of the session
The hook is hooked up to the agent at development—instruments stay utterly unaware of the approval logic:
agent = Agent(
hooks=[ApprovalHook()],
instruments=[get_patient_name, get_patient_condition, get_patient_vitals],
)
Methodology 2: Software context interrupt
As a substitute of a centralized hook, the approval logic is embedded immediately inside every software utilizing tool_context.interrupt(). This provides fine-grained, per-tool management: every software can implement its personal entry guidelines primarily based on session context. On this instance, the agent session carries a user_role. A shared check_accessfunction enforces role-based entry: In our code instance, Non-Physicians are denied outright, whereas Physicians are prompted for approval: Like Methodology 1, the belief choice caches approval for the session:
def check_access(tool_context, patient_id: str, motion: str):
user_role = tool_context.agent.state.get(“user_role”) or “Non-Doctor”
if user_role != “Doctor”:
return f”Entry denied: {motion} requires Doctor function (present: {user_role})”
approval_key = f”{motion}-{patient_id}-approval”
if tool_context.agent.state.get(approval_key) == “t”:
return None # beforehand trusted
approval = tool_context.interrupt(
approval_key,
cause={“cause”: f”[{user_role}] Authorize {motion} for affected person {patient_id}”},
)
if approval.decrease() not in [“y”, “yes”, “t”]:
return f”Doctor denied entry to {motion} for affected person {patient_id}”
if approval.decrease() == “t”:
tool_context.agent.state.set(approval_key, “t”)
return None # accepted
Methodology 3: Asynchronous software approval utilizing AWS Step Features
In lots of enterprise situations, the approval movement requires authorization from a third-party approver who will not be the individual invoking the agent. This necessitates an asynchronous approval workflow that may function independently of the agent session. One efficient method makes use of AWS Step Features to orchestrate these exterior approval processes.
On this sample, the agent software triggers a Step Features workflow that sends an approval request to an exterior approver by way of e-mail notification by way of Amazon SNS. The software polls for the approval outcome and updates the agent session state accordingly. The person also can examine the approval standing later utilizing a separate check_discharge_status software. The discharge_patient software begins the Step Features execution and polls for the outcome:
@software(context=True)
def discharge_patient(tool_context, patient_id: str, cause: str) -> str:
# Skip workflow if already accepted on this session
if tool_context.agent.state.get(“external-approver-state”) == “accepted”:
return f”Affected person {patient_id} discharged (pre-approved). Motive: {cause}”
response = sfn_client.start_execution(
stateMachineArn=state_machine_arn,
enter=json.dumps({“patient_id”: patient_id, “motion”: “discharge”, “cause”: cause}),
)
return f”Ready for approval. Execution ARN: {response[‘executionArn’]}”
This asynchronous method allows non-blocking operations the place customers aren’t compelled to attend for approvals that may take hours or days, and agent execution can proceed independently. Step Features maintains detailed audit trails with full execution historical past, persistent state administration throughout session timeouts, and integration with present enterprise communication channels like e-mail, Slack, or Microsoft Groups. The person that begins a delicate workflow will set off a State Perform: The agent returns a affirmation to the person that the workflow was launched. Always, the person can examine for a state replace to be sure that the workflow accomplished.
Methodology 4: MCP elicitation
The MCP protocol just lately launched the elicitation protocol that permits MCP servers to request extra data or approval from customers throughout software execution. This method follows protocol requirements and supplies a dynamic mechanism for prompting customers at runtime with out requiring parameters to be hardwired upfront. It may be used to authorize a software name and embrace some enterprise justification.
When a delicate software known as, the MCP server pauses execution and sends an approval immediate again by way of the MCP shopper to the tip person. The person sees the immediate, decides, and the server resumes—both continuing with the operation or denying entry. This two-way communication is enabled by MCP’s streamable HTTP transport, which maintains a stateful connection between shopper and server.
On the MCP server, the approval logic is a single ctx.elicit() name inside every delicate software:
@server.software
async def get_patient_condition(patient_id: str, ctx: Context) -> str:
“””Get affected person situation. Delicate — requires approval by way of MCP elicitation.”””
outcome = await ctx.elicit(
f”⚠️ Approve entry to SENSITIVE situation information for affected person {patient_id}?”
)
if outcome.motion != “settle for”:
return f”Entry to situation information for affected person {patient_id} DENIED.”
return f”Affected person {patient_id} situation: Hypertension Stage 2, Kind 2 Diabetes”
On the agent facet, an elicitation_callback is registered with the MCP shopper. When the server calls ctx.elicit(), this callback fires, relaying the approval immediate to the person and returning their resolution again to the server. For native brokers, this can be a terminal immediate. For brokers deployed on AgentCore Runtime, we use a WebSocket connection to relay the elicitation to the distant finish person in actual time:
This method retains the approval logic solely inside the MCP server’s software definitions. The agent itself has no information of which instruments require approval, so you may add or modify approval necessities independently.
Conclusion
You should utilize these human-in-the-loop (HITL) constructs to construct secure, compliant AI agent deployments in healthcare and life sciences. By implementing the suitable HITL sample on your use case, you may deploy production-ready workflows that scale from pilot tasks to enterprise-wide deployments. Begin by figuring out which operations in your workflow require human oversight. Then, choose the HITL sample that matches your approval necessities—centralized (Methodology 1), tool-specific (Methodology 2), asynchronous (Methodology 3), or real-time (Methodology 4).
For extra details about Amazon Bedrock AgentCore, go to the Amazon Bedrock AgentCore documentation.
In regards to the creator
Pierre de Malliard
Pierre de Malliard is a Senior AI/ML Options Architect at Amazon Net Companies and helps prospects within the Healthcare and Life Sciences Trade. Pierre has 10+ years of expertise constructing Machine Studying Functions and Platforms. In his spare time, he enjoys taking part in the piano and having fun with nature.

