Reducing Patient Intake latency with Responses API compaction

AI-500 By islever Editorial Last updated

Design and implement agent memory, context management, and knowledge integration Optimize prompt and model performance for multi-agent solutions

Short answer

D Use stateful Responses API calls with previous_response_id and periodically call /responses/compact to shrink history while preserving critical triage details.

Question

This is a case study. Case studies are not timed separately. You can use as much exam time as you would like to complete each case. However, there may be additional case studies and sections on this exam. You must manage your time to ensure that you are able to complete all questions included on this exam in the time provided.
To answer the questions included in a case study, you will need to reference information that is provided in the case study. Case studies might contain exhibits and other resources that provide more information about the scenario that is described in the case study. Each question is independent of the other questions in this case study.
At the end of this case study, a review screen will appear. This screen allows you to review your answers and to make changes before you move to the next section of the exam. After you begin a new section, you cannot return to this section.
To start the case study
To display the first question in this case study, click the Next button. Use the buttons in the left pane to explore the content of the case study before you answer the questions. Clicking these buttons displays information such as business requirements, existing environment, and problem statements. If the case study has an All Information tab, note that the information displayed is identical to the information displayed on the subsequent tabs. When you are ready to answer a question, click the Question button to return to the question.
Overview
Contoso, Ltd. is a health provider. The company is building an Azure-based multi-agent solution to streamline patient triage, access historical medical records, and schedule specialist appointments.
Existing Environment
Microsoft Foundry
Contoso has a Microsoft Foundry project named HealthAssist that contains the following agents:
Patient Intake: A public-facing chat interface where patients describe their symptoms
Record Retrieval: An internal system that retrieves a patient's past medical history from a secure database
Scheduling: Integrates with an external third-party booking system by using a Model Context Protocol (MCP) server
Lead Orchestrator: A workflow agent that makes decisions based on the output of the other agents
Knowledge Base
Contoso uses a Retrieval-Augmented Generation (RAG) system that contains clinical documents. Only the Patient Intake agent can access the RAG system.
Problem Statements
Contoso identifies the following issues:
The MCP server used by the Scheduling agent frequently times out during peak load.
Patients report that during the intake process, the session frequently times out silently without indicating why. The issue occurs during workflow execution.
Occasionally, the Patient Intake agent cannot extract relevant symptoms when patients provide verbose personal stories that are irrelevant to the medical issue.
When the Patient Intake agent engages in long, multi-turn conversations with patients, the accumulating conversation history causes high latency due to massive prompt sizes and risks that exceed the model's context window.
Requirements
Business Requirements
Contoso identifies the following business requirements:
A physician must approve any triage assessments that recommend an emergency room visit.
HealthAssist must be able to handle large spikes in concurrent patient intake requests during flu season.
Before releasing updates to HealthAssist, the clinical team must review the accuracy of the Lead Orchestrator agent triage routing decisions against a set of historical test cases.
Safety Requirement
Contoso identifies the following safety requirements:
Implement a robust guardrail strategy to prevent HealthAssist from providing inappropriate medical diagnoses.
Ensure that all public-facing agents block violence and hate speech.
Prevent hardcoding new logic into the agents' core prompt.
Consultant Proposal
A consulting firm proposes the following solution to address various requirements and issues:
Add a guardrail that has the highest sensitivity for all controls.
Add a system prompt message to direct the agent to ignore hate speech.
Implement a short-term memory context window that prompts patients multiple times to verify their symptoms.
Add a system prompt message to direct the agent to recommend an emergency room visit if the patient is having heart palpitations.
Security Requirements
Contoso identifies the following security requirements:
Ensure that the agents do NOT have overlapping permissions to prevent lateral movement.
Prevent the agents from accessing patients' data outside of the current patient context.
Ensure that all API keys are securely stored and rotated.
Follow the principle of least privilege, when possible.
Performance Requirements
Contoso identifies the following performance requirements:
Token usage must be monitored.
Long-term semantic memory must be isolated by patient.
You need to resolve the high latency issue for the Patient Intake agent. The solution must preserve a compacted version of critical triage details.
  1. Store each conversation turn as a separate document in an Azure Cosmos DB database. Configure the database's full-text search index to automatically summarize the context before model inference.
  2. Use standard HTTP requests. Configure a manual sliding window that truncates the oldest 50 percent of the text after every 10 conversation turns.
  3. Set store=false on the Responses API. Configure the Lead Orchestrator agent to inject a full summary at the start of every turn.
  4. Implement the Responses API in WebSocket mode to send incremental inputs by using previous_response_id. Periodically call the standalone /responses/compact endpoint. Correct Answer

Key Takeaways

The question tests context-management strategy: it rewards real compaction of conversation history and traps you with a sliding-window truncation that lowers latency by deleting the very triage details you must preserve.

This AI-500 case asks how to cut prompt-driven latency for Contoso's Patient Intake agent while keeping a compacted record of critical triage details. The correct approach (D) combines incremental Responses API inputs via previous_response_id with periodic calls to /responses/compact.

Common mistake: Option B is the most plausible wrong answer: a manual sliding window that drops the oldest 50 percent of text every 10 turns does reduce prompt size, but it discards rather than compacts early symptoms, violating the requirement to preserve critical triage details.

Expert Analysis

The trap: B's manual sliding window

Option B is the most seductive wrong answer because it directly attacks the stated symptom. The problem is high latency from massive prompt sizes, and a sliding window that drops the oldest 50 percent of text every 10 turns will absolutely shrink the prompt and cut inference latency. It even appears to respect the history by keeping a "window" rather than wiping everything. But the requirement adds a second condition that B silently fails: the solution "must preserve a compacted version of critical triage details." Truncation is deletion, not compaction — the first symptoms a patient described in turn 1 are exactly the content that gets discarded, and those are the details a triage assessment depends on. A hard-coded 50 percent / 10-turn rule is also arbitrary logic that would need to be re-tuned whenever conversation patterns change.

Why D is correct

Option D satisfies both halves of the requirement. Sending only the new user input by reusing previous_response_id means each turn's prompt grows by the new message alone instead of replaying the entire transcript, which addresses the latency root cause. Then, periodically calling the standalone /responses/compact endpoint replaces the accumulated turns with an AI-generated condensed form that retains important content — genuine compaction rather than truncation — so critical triage details survive while token counts drop.

Why the other options fail

Option C pairs store=false with the Lead Orchestrator injecting a "full summary" each turn; disabling storage removes server-side state entirely, forces the orchestrator to build and ship a summary that is by definition not compacted, and pushes summarization work back into the hot path. Option A assumes Azure Cosmos DB full-text search indexes can "automatically summarize the context before model inference," which is not a real capability.

Exam Strategy

When a question pairs a latency complaint with a preservation constraint, treat the constraint as a second gate the answer must also pass. Options that merely shrink the prompt by deleting content (sliding windows, fixed truncation percentages) fail instantly. Look for the mechanism that both reduces per-turn tokens and produces an explicit compaction artifact, and be suspicious of any option that disables server-side state while still depending on server-side history.

Frequently Asked Questions

Why doesn't a sliding window solve the Patient Intake latency problem?

A sliding window reduces prompt size by discarding old turns, but it truncates rather than compacts. The earliest symptoms a patient reports can be deleted outright, breaking the requirement to preserve a compacted version of critical triage details.

What does previous_response_id do in the Responses API?

It lets each new turn reference a stored prior response, so the API appends only the new user input instead of resending the full transcript. This keeps per-turn token growth minimal while retaining server-side conversation state.

More AI-500 FAQ →

Community Votes

D
100%

100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 2 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 2

  1. ExamProAzure 👍 1 Answered D
    Incremental inputs with previous_response_id: Each turn sends only the new user input. Periodic compaction: Calling the compact endpoint shrinks the accumulated conversation into a condensed form that keeps the important content, so triage details survive while the token count drops
  2. ExamProAzure 👍 1 Answered D
    Manual sliding window dropping the oldest 50 percent: Truncation is blunt and can discard critical early details, such as the first symptoms the patient reported. It doesn’t preserve a compacted version of them.

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

← Back to AI-500 Study Guide