Troubleshooting context limits and API errors: AIP-C01 study notes and practice questions
What to know about Troubleshooting context limits and API errors for the AIP-C01 exam, from the Testing, Validation, and Troubleshooting domain (11% of the exam guide), then 1 free question to test it. Part of the AIP-C01 study guide.
Each error points to a different owner of the fix: the request body, the quota, the service, or the IAM setup. Match the symptom to its cause before you change code.
Input exceeds the context window
A ValidationException that says the input is too long means the prompt, including any history, is larger than the model’s context window. Trim the conversation history, retrieve fewer chunks, or split the document. For long documents, split by sections that fit the window, summarize each part, then combine the summaries.
Truncated output
A response that ends early with stopReason set to max_tokens was cut off by the output limit. Raise maxTokens only if the answer genuinely needs more room, and check whether the prompt asks for more than the task needs. A response that ends at a stop sequence is intended, not truncated.
Throttling and service errors
ThrottlingException (HTTP 429) means a quota was hit. Retry with exponential backoff and jitter, smooth load with a queue, use cross-Region inference, or request a quota increase. ServiceUnavailableException (HTTP 503) means temporary capacity or service trouble. Retry with backoff, and for critical paths fall back to another model or Region. Do not retry a ValidationException, because the request itself is wrong and will fail again.
Access denied
AccessDeniedException means the caller lacks permission. Bedrock serverless models no longer need to be enabled one by one on a model access page, so access is decided by IAM and SCPs (some third-party models also need AWS Marketplace permissions, and Anthropic models need a one-time use case form). Check that the IAM policy allows the invoke action on the model or inference profile ARN, and that no service control policy denies the Region or model. A cross-Region profile needs permission on the destination Regions as well.
Malformed request body
A ValidationException about the body means the request does not match the model’s schema. The Converse API uses one request shape across models, so it avoids most per-model body errors that InvokeModel can produce.
How to choose
Scenario wording
Choose
ValidationException, input too long
Trim history, retrieve fewer chunks, or split and summarize
Answer stops mid-sentence with max_tokens
Raise maxTokens only if needed, and shorten the task
ThrottlingException or HTTP 429
Backoff with jitter, a queue, cross-Region inference, or a quota increase
ServiceUnavailableException
Retry with backoff, then fall back to another model or Region
AccessDeniedException on a model
Check the IAM resource ARN, SCPs and Marketplace permissions
Body rejected for one model
Switch to the Converse API
Common traps
Retrying a ValidationException. The same bad request fails again.
Raising maxTokens for an input-size error, which concerns the input, not the output.
Granting broad admin rights to fix AccessDenied, instead of the specific model or profile ARN.
Ignoring the stop reason, so a truncated answer looks like a model bug.
Retrying immediately with no jitter, which keeps the throttle hot.
A law firm's document assistant helps attorneys review long case files. Each turn, the application sends the full conversation history and every retrieved passage to a model on Amazon Bedrock. Sessions have grown long, and some turns now fail with a ValidationException that says the input is too long for the model.
Attorneys often run sessions of 50 turns or more, and the team needs those sessions to keep working. The answers to recent questions must not change, and the fix should not raise the cost per turn by much.
Which fix meets these requirements?
Choose one answer.
AA. Count input tokens before each call and, when over budget, summarize the oldest turns and drop low-ranked passages, keeping recent turns verbatim.
BB. Increase the maximum output tokens for each call so that the model has more room to hold the conversation and the retrieved passages.
CC. Catch the ValidationException and retry the call with exponential backoff, since the limit is usually reached only briefly during peak hours.
DD. Ask Amazon Bedrock for a higher tokens-per-minute quota for the model, so the account can send longer inputs without errors at busy times.
Show the answer and explanation
Answer: A
A. Right: Checking the size before each call prevents the ValidationException, and summaries keep older context at a fraction of the tokens. Recent turns stay verbatim, so the answers to current questions do not change.
B. Wrong: The maximum output tokens limit the length of the reply, not the input. A larger limit does not make a too-long input fit.
C. Wrong: Backoff is for throttling, which is temporary. An input that is too long fails every time, so retries would only add delay and cost.
D. Wrong: Quotas limit throughput across requests, not the number of tokens in a single request. A higher quota would not let one oversized input fit into the model's context window.
Explanation
A ValidationException for a too-long input means the single request exceeds the model's context window, so fixing it means reducing the input. Counting tokens before each call, summarizing older turns and dropping low-ranked passages keeps the input within budget while preserving recent context. Raising output limits, retrying or raising quotas do not change the size of the input.
Want more on Troubleshooting context limits and API errors? The 5 full-length practice sets have 5 more Troubleshooting context limits and API errors questions, 375 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →
Study Troubleshooting context limits and API errors