Get Your CertMicrosoft Applied Skills: Develop a Generative AI Chat App Using the Microsoft Foundry SDKPlayCompete
‹ All Microsoft Applied Skills: Develop a Generative AI Chat App Using the Microsoft Foundry SDK questions

Microsoft Foundry Generative AI Chat App Practice Question 10: Long Conversation Compaction

Microsoft Applied Skills: Develop a Generative AI Chat App Using the Microsoft Foundry SDK · Test 1 · question 10 of 10

Implement chat historyhard

A coding-assistant chat app keeps a single session open for hours. Turns are chained correctly, but after roughly forty exchanges requests begin failing because the accumulated history exceeds the model's context window. Truncating the oldest turns loses decisions the assistant still needs to honour later in the session. Which Responses API feature addresses this directly?

Select one answer
Show answer and explanation

Answer:

  • C. Add a context_management compaction item with a compact_threshold to the request

The Responses API supports server-side compaction for exactly this case: context_management=[{"type": "compaction", "compact_threshold": 200000}]. When the conversation crosses the threshold, the service compacts it, and "the compaction item carries the context needed for the next window." It works with either chaining style; with stateless input-array chaining you append output items as usual, and with previous_response_id you pass only the new user message each turn. That preserves the earlier decisions instead of discarding them.

- A is wrong because store governs whether response data is retained on the service (by default it is kept for 30 days). It does not shrink what a given request sends, so the context window overflow is unchanged. - B is wrong because the system message is a small fraction of a forty-turn history, so removing it barely helps, and it is the part that defines the assistant's behaviour, so dropping it degrades every later turn. - D is wrong because a fresh conversation discards exactly the accumulated decisions the stem says must be honoured. Replaying only the first user message does not bring them back.

Reference: Use the Azure OpenAI Responses API

Practice Test 1 ›