Repository navigation
LiteLLM 2 · Fallbacks, retries and routing that does not degrade silently #22
akash-coded
started this conversation in
Exercises
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Exercise · LiteLLM · Final
Language: Python · Topics: fallbacks, retries, routing, cost, structured output, Strands / LangChain / LangGraph integration · Level: Applied
Scenario
TravelMind's bot survived launch. Now it must not fall over under Diwali-rush load, must track spend per feature, and must plug into the Strands agent the team already built. You will read, debug, and complete small pieces.
flowchart LR R[Request] --> P[Primary: haiku 4.5] P -->|429 / error| F[Fallback: sonnet] P -->|ok| D[Answer] F --> DRelative cost intuition (illustrative bars, not exact prices):
Part A · Read the resilience layer (MCQ)
Q1. In this Router, what happens when
primaryerrors?backupand returns its answerQ2.
num_retries=3oncompletion()handles which class of failure best?Q3.
litellm.completion_cost(completion_response=resp)returns:Part B · Multi-select
Q4. Which of these are correct about the Bedrock temperature + top_p conflict? (choose all)
top_p=1.0, tripping it unexpectedlylitellm.drop_params = Trueremoves the unsupported parammax_tokensPart C · Predict the output
Q5. Given the Router in Q1, when
router.completion(model="primary", ...)runs successfully, which deployment produced the answer, and why?Q6. What does this print, structurally (not the exact fact)?
Part D · Match feature to call
Q7. Match. One is a distractor.
litellm.embedding(model="bedrock/amazon.titan-embed-text-v2:0", ...)Router(..., fallbacks=[{"primary": ["backup"]}])litellm.completion_cost(completion_response=resp)Router(model_list=[... same model_name twice ...])litellm.moderation(...)Part E · Spot the wrong line and fix it (free fix)
Q8. This Router config will not balance as intended. Identify the wrong part and write the one-line correction.
Q9. A teammate's tool-calling code fails only when streaming. Identify the bug and give the one-line fix.
Part F · Rectify the wrong suggestion
Q10. A teammate says: "For Bedrock, put the AWS key in
LiteLLMModel(client_args={'api_key': ...})like we do for OpenAI." Explain why this is wrong and state the correct approach in one line.Part G · Read the Strands integration (MCQ + predict)
Q11. For Strands on Bedrock through LiteLLM,
model_idshould be:anthropic.claude-haiku-4-5-20251001-v1:0bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0us-east-1/claudeopenai/claudeQ12. Predict what
percent_ofreturns when the agent answers "What is 15 percent of 240?"Part H · Complete the code (small)
Q13. Fill the two blanks so this Strands agent runs on Bedrock through LiteLLM.
Q14. Fill the blank so
primaryfalls back tobackup.Part I · Case study
Q15. Five teams at TravelMind share one AWS account and keep hitting each other's rate limits and spend. SDK in each app, or the LiteLLM Proxy? Pick one and give two reasons tied to the symptoms.
Part J · Skeptic check
Q16. "Abstraction always wins, so route everything through LiteLLM." Give one case where the native SDK is the better call, and why.
All reactions