‹ All AI-103 questions

AI-103 Practice Question 65: Chat Completions History Truncation

Microsoft Azure AI Apps and Agents Developer Associate (AI-103) · Test 7 · question 5 of 10

Implement generative AI and agentic solutionseasy

A developer builds a support chatbot by calling the Azure OpenAI chat completions API directly: each turn, the app appends the new user message to a list and resends the entire list as the messages array. After about 40 turns in one long session, requests start failing with an error about exceeding the model's maximum context length.

What is the most likely fix?

Select one answer
Show answer and explanation

Answer:

  • B. Have the app trim or summarize the oldest turns before each call, keeping the system message and only the most recent history within the model's token limit

The chat completions API is stateless: the caller is responsible for what goes in messages on every request, and Microsoft's guidance is direct: "it's your responsibility to ensure that the prompt and completion fall within the token limit," with truncation strategies such as removing the oldest complete turns while preserving the system message. That is exactly the app's problem: it resends unbounded history instead of managing it.

- A is wrong because a deployment's SKU governs throughput and capacity (tokens per minute, concurrency), not the model's maximum context length, which is a property of the model itself. - C is wrong because prompt caching reduces latency and cost for a repeated prefix; it does not change how many tokens count toward the context window; the full prompt is still subject to the limit. - D is wrong because Foundry Agent Service threads have a large but still finite message limit (up to 100,000 messages) and the service manages truncation for *its own* context assembly; switching architectures is a bigger change than the problem calls for, and it doesn't describe what the chat completions caller itself must do.

Reference: Work with chat completion models

Practice Test 7 ›

Study guides for AI-103

AI engineer roadmap 2026: skills, certs and the orderAI engineer roadmap for 2026: skills to learn in order, AI engineer vs ML engineer, which certifications fit each stage, and what to skip.
AI-200 exam guide: Azure AI Cloud Developer AssociateAI-200 replaced AZ-204: what the Azure AI Cloud Developer exam tests, how it differs from AI-103, price in USD and INR, format and how to prepare.
How AI Is Changing Software Jobs: Where to PrepareHow AI is changing software jobs: what history shows, the evidence on junior developers, what Klarna learned, new AI roles and five domains to prepare for.
AI-901 exam guide: Azure AI Fundamentals after AI-900AI-901 replaced AI-900: learn what changed, how much Python and Microsoft Foundry you need, exam costs in India, and how to prepare.
Best AI certifications 2026: AWS, Google, Microsoft, ClaudeThe best AI certifications in 2026 from AWS, Google, Microsoft, Claude and Databricks, by level, with price, status and which one to take first.
Microsoft AI certification path 2026: which exam firstMicrosoft AI certification path for 2026 - AI-901, AB-730, AI-103, AI-200, AI-300, AB-100, AI-500 and GH-300 by role, and which exam to take first.
AI-103 Certification Guide: What Changed From AI-102The AI-103 certification replaced AI-102 in 2026. Exam format, cost, the five skill domains, what changed and how to prepare, with free practice questions.
What Is RAG? How Retrieval-Augmented Generation WorksWhat RAG is and how it works: chunking, embeddings, vector search, hybrid search, reranking, GraphRAG and agentic RAG on AWS, Google and Azure.
Prompt engineering vs RAG vs fine-tuningWhen to use prompt engineering, retrieval-augmented generation, fine-tuning or continued pre-training, compared on cost, freshness, hallucination and privacy.