Executive summary

Business problemCoordinators lost time searching payer policies, SOPs and scheduling screens while patients waited, and answers varied from person to person.
SolutionA read-only AI agent grounded in approved policy documents, with live, identity-aware access to scheduling and referral data.
PlatformMicrosoft Foundry Agent Service, Azure AI Search, Azure API Management, Microsoft Entra ID, Azure AI Content Safety, Application Insights.
Risk posturePrivate networking, per-user authorization, field masking, human approval for patient messages, and a full audit trail.
Value leversFaster answers, fewer denials from missed prior authorization steps, consistent answers, and quicker onboarding of new staff.

The problem: answers buried in a hundred places

Before the agent, a coordinator handling a referral might check payer policy PDFs, clinic SOPs, the prior authorization matrix and the scheduling system—often while the patient waited on the line. The context was fragmented, the same question could produce different answers, and important steps were easy to miss during a busy shift.

The Care Navigator answers practical questions in plain language: “Does this payer need prior authorization for an outpatient MRI, and what documents go with it?”, “What is the next open cardiology slot at the Back Bay clinic, and has this referral been received?”, or “Draft a message telling the patient what to bring to their first appointment.” Every response cites the policy or system it came from. Version one only reads data; anything sent to a patient waits for a staff member to review and approve it.

Why Microsoft Foundry, not just Copilot

The key decision was to choose a platform suited to a governed, tool-using agent that needs production networking, identity and evaluation—not just a chat surface.

OptionGood fit whenWhy not for this build
Microsoft 365 CopilotPeople need an assistant embedded in familiar Microsoft 365 apps and work content.This workflow needs custom orchestration, controlled clinical-system tools and application-specific evaluations.
Copilot StudioTeams need low-code conversational workflows, connectors and business-user extensibility.The design calls for code-first lifecycle control, a custom retrieval pipeline and service-level integration policies.
Microsoft Foundry Agent Service — ChosenTeams need a managed agent runtime with model choice, tools, evaluation and tracing.Selected because it aligns with the required agent lifecycle and supports the chosen network and governance pattern.

Foundry brought the core agent capabilities together: model choice from the catalog (a GPT-5-class model and text-embedding-3-large), built-in agent tools for file search, Azure AI Search, OpenAPI and MCP servers, a standard agent setup with bring-your-own VNet, and integrated evaluations, tracing and safety controls.

The architecture

Design principle: the agent reasons and retrieves, but it never becomes an authorization boundary. Entra ID establishes the user; downstream services enforce access; API Management masks fields and applies policy; and staff remain responsible for patient-facing actions.

LayerServiceRole
ExperienceMicrosoft TeamsWhere coordinators ask questions.
IdentityMicrosoft Entra IDSign-in, group-based roles and on-behalf-of tokens.
Agent runtimeMicrosoft Foundry Agent ServiceOrchestration, tool calling, threads and agent versions.
ModelsGPT-5-class + text-embedding-3-largeReasoning and retrieval.
KnowledgeAzure AI SearchHybrid index with semantic ranking and security filters.
IntegrationAzure API ManagementMCP endpoint; token exchange, masking, quotas and logging.
SafetyAzure AI Content SafetyPrompt Shields for direct and indirect attacks.
StateAzure Cosmos DB, Azure Storage, Azure Key VaultThreads, files and secrets behind private endpoints.
ObservabilityApplication Insights, Foundry tracingTraces, latency, tokens and continuous quality scoring.
DeliveryBicep, pipelines on self-hosted runnerRepeatable dev, test and production environments.

Anatomy of one request

  1. A coordinator signs in to Teams with Microsoft Entra ID and asks a question.
  2. Content Safety checks the input for direct prompt attacks and unsafe content.
  3. The model plans whether the request needs policy retrieval, a system lookup, or both.
  4. Azure AI Search runs a hybrid query with effective-date and group-based security filters.
  5. The agent calls the relevant API Management MCP operation using an on-behalf-of identity.
  6. API Management and the downstream service authorize the user; the gateway masks unnecessary fields.
  7. Prompt Shields inspect retrieved content as untrusted input before it is used in the response.
  8. The agent answers with citations in the coordinator’s Cosmos DB-backed thread; a patient message remains a draft until staff approval.

The build, A to Z

A. Frame the problem before writing any code

We wrote a problem contract with the intended users, supported questions, data owners, measurable outcomes and explicit non-goals. Version one is read-only: no appointment booking, referral changes or message sending. The red-team plan covered prompt injection in documents, cross-user access, stale policies, ambiguous patient matching and requests for more information than a coordinator needs.

B. Provision the Foundry resource

We chose a Standard agent setup, aligned the resource and project with the approved network design, and planned private endpoints for data and state services. Bicep provisions dev, test and production consistently. Entra roles follow least privilege: developers manage non-production resources, while the runtime receives only the permissions required for approved tools and indexes.

C. Notebook 01: connect and smoke-test

The first notebook authenticates through the developer’s configured identity and verifies that the project endpoint and model deployment are reachable. Credentials stay out of the notebook; local development uses DefaultAzureCredential, while deployed workloads use managed identity.

# 01_connect.ipynb
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

PROJECT_ENDPOINT = "https://<foundry>.services.ai.azure.com/api/projects/<project>"
project = AIProjectClient(endpoint=PROJECT_ENDPOINT, credential=DefaultAzureCredential())

client = project.get_openai_client()
r = client.responses.create(model="chat-deploy", input="Reply with OK if you can read this.")
print(r.output_text)

D. Notebook 02: ground the agent in policy documents (RAG)

Approved payer policies, SOPs and authorization matrices are normalized, chunked with source metadata and indexed in Azure AI Search. The index stores content, content_vector, title/source_url, doc_type, payer/service_line, effective_date/expiry_date and acl_groups. A hybrid text-and-vector query is combined with semantic ranking; the filter restricts results to the user’s groups and currently effective documents.

Index fieldPurpose
contentSearchable text chunk from the approved source.
content_vectorEmbedding used for vector retrieval.
title / source_urlHuman-readable source identity and citation link.
doc_typeDistinguishes payer policies, SOPs and authorization matrices.
payer / service_lineEnables scoped retrieval for the payer and service in the question.
effective_date / expiry_dateSupports current-policy filtering and citation freshness checks.
acl_groupsRestricts retrieval to the caller’s authorized groups.
filter_expr = (
    f"acl_groups/any(g: search.in(g, '{','.join(user_group_ids)}')) "
    f"and effective_date le {today} and (expiry_date ge {today} or expiry_date eq null)"
)

In production, group identifiers and dates are validated and safely encoded by the query layer. Each returned chunk retains its source and effective dates so citations can be checked and displayed.

E. Notebook 03: expose clinical systems as tools

Scheduling and referral data are exposed through narrowly scoped, read-only MCP operations. The gateway verifies the caller’s delegated identity, validates inputs, applies quotas, masks fields that are not needed and records an audit event.

MCP operationPurposeGuardrail
get_coverageLook up coverage details relevant to a payer and service.Return only the minimum coverage fields needed for the question.
get_referral_statusCheck whether a referral was received and its current status.Require an authorized patient/referral identifier and enforce caller access.
find_open_slotsFind available appointment slots by specialty and clinic.Return availability only; creating or changing appointments is out of scope.
get_patient_summaryRetrieve the limited patient context needed to coordinate a referral.Apply field-level masking and authorization before returning results.

The following illustrates the gateway policy shape; production policies also validate the identity provider’s claims and use environment-specific named values.

<policies>
  <inbound>
    <base />
    <validate-jwt header-name="Authorization" failed-validation-httpcode="401">
      <openid-config url="{{entra-openid-config}}" />
      <required-claims>
        <claim name="aud" match="all"><value>{{api-audience}}</value></claim>
      </required-claims>
    </validate-jwt>
    <rate-limit-by-key calls="60" renewal-period="60"
      counter-key="@(context.Request.IpAddress)" />
  </inbound>
  <backend><base /></backend>
  <outbound>
    <base />
    <set-header name="X-Request-ID" exists-action="override">
      <value>@(context.RequestId.ToString())</value>
    </set-header>
  </outbound>
  <on-error><base /></on-error>
</policies>

F. Notebook 04: create the agent

The agent receives only the tools needed for the read-only workflow. Tool schemas constrain inputs; service-side authorization remains authoritative. The example below is a wiring sketch—the deployed project’s current SDK version and tool registration format are pinned and validated in its build.

# 04_create_agent.ipynb — illustrative tool wiring
from azure.ai.projects.models import AzureAISearchTool, MCPTool

search_tool = AzureAISearchTool(
    connection_id=SEARCH_CONNECTION_ID,
    index_name="care-navigation",
)
mcp_tool = MCPTool(
    server_label="care-systems",
    server_url=APIM_MCP_ENDPOINT,
    allowed_tools=[
        "get_coverage",
        "get_referral_status",
        "find_open_slots",
        "get_patient_summary",
    ],
)

agent = project.agents.create_agent(
    model="chat-deploy",
    name="Boston HealthCare Care Navigator",
    instructions=AGENT_INSTRUCTIONS,
    tools=[search_tool, mcp_tool],
)

Instructions:

You are the Boston HealthCare Care Navigator for authorized coordinators.
Answer using approved, currently effective policy sources and authorized tool results.
Cite each material claim with its source and effective date. If evidence is missing,
stale, conflicting, or the caller is not authorized, say so and do not guess.
Use only read-only tools. Never book or change appointments, alter referrals, or send
patient communications. You may draft a patient message, but a staff member must
review and approve it before it is sent. Minimize patient information in every reply.

Keeping PHI safe: security, privacy and responsible AI

Control areaImplementation approach
BAA scopeConfirm the healthcare entity’s agreements and service configuration cover every component that can process or store PHI before production use.
Network isolationUse private connectivity for the agent, search, storage, Cosmos DB and Key Vault where supported; restrict public ingress and egress.
Identity and least privilegeUse Entra ID, delegated/on-behalf-of access, managed identities and role-specific permissions; enforce authorization in each downstream system.
Data minimizationRetrieve only the fields needed for the request, mask sensitive fields at the gateway, and define retention for prompts, traces and thread data.
Content safetyApply Prompt Shields to user input and retrieved content, test adversarial documents and keep untrusted content separate from instructions.
Human in the loopPatient-facing messages are drafts only until an authorized staff member reviews and explicitly approves them.

Audit is built into the request path: user and tool identity, operation, timestamp, result status, source citations and approval events are correlated with a request ID. Logs are access-controlled and configured to avoid retaining unnecessary PHI.

Proving it works: evaluation, observability and go-live

# 06_evaluate.ipynb
from azure.ai.evaluation import (evaluate, GroundednessEvaluator, RelevanceEvaluator,
                                 TaskAdherenceEvaluator, ToolCallAccuracyEvaluator)
result = evaluate(
    data="golden_set_v3.jsonl",
    evaluators={
        "groundedness": GroundednessEvaluator(model_config),
        "relevance": RelevanceEvaluator(model_config),
        "task_adherence": TaskAdherenceEvaluator(model_config),
        "tool_accuracy": ToolCallAccuracyEvaluator(model_config),
        "current_policy": cites_current_policy,
    },
    azure_ai_project=PROJECT_ENDPOINT,
)
Release gateEvidence required before expansion
Groundedness and relevanceEvaluation thresholds agreed with clinical operations are met on the approved golden set.
CitationsAnswers cite traceable, current sources; stale or missing evidence is clearly surfaced.
AuthorizationPositive and negative user/group access tests pass for search and every tool.
Red-teamCritical prompt-injection, privacy and unsafe-action scenarios are mitigated and retested.
PerformanceLatency, reliability and capacity meet the agreed service objectives under representative load.

What changed, and what we learned

  1. Start with a narrow problem contract and explicit non-goals; it makes the first safe release measurable.
  2. Treat authorization as an end-to-end property. A prompt cannot replace downstream access checks.
  3. Make freshness and provenance first-class retrieval data so citations can be evaluated, not merely displayed.
  4. Keep write actions separate from read workflows. Drafting is useful; sending still requires a human decision.
  5. Build evaluation and observability alongside the agent. Quality, safety and operational readiness are release criteria.

Build your own agent with CodeSizzler

CodeSizzler is a Microsoft Preferred Partner for Data & AI, led by a Ex-Microsoft MVP (Azure) and Microsoft Certified Trainers. We design, build and run production AI agents on Microsoft Foundry and Copilot Studio.

Talk to us: sales@codesizzler.in · codesizzler.in · +91 90801 16454