← Questions

Solve math questions with an LLM: tools and chains

0
TeslaSystem designLast asked Jul 2025

An AI system design interview question asked in Tesla's system design round, last asked Jul 2025. It tests llm, tool use and agents.

Design a system that uses an LLM to answer arithmetic and math questions, from simple expressions such as "what is 4 + 5?" to tasks such as "what is the sum of the integers from 1 to 100?". Decide when the model should answer directly, when it should apply a known formula, and when it should call a tool (a calculator or a Python sandbox). The answers must be correct, and you must be able to show it.

Requirements

  • Functional: accept a question in plain language; route it to a direct answer, a formula or a tool; run the chain of steps; return the answer and, optionally, the working.
  • Non-functional: high accuracy on exact arithmetic; low latency and cost for easy questions; safe code execution; every experiment tracked and reproducible.

Clarifying questions

  • What range of questions: arithmetic only, algebra, word problems, proofs?
  • Must the answer be exact (big integers, fractions) or is a rounded float acceptable?
  • Latency and cost budget per question?
  • Is a chain framework (for example LangChain) required, or is a hand-written loop fine?
  • Who uses the answers, and what happens when the system is unsure?

What a strong answer covers

  • Routing: let the model answer from memory only for trivial cases; send exact arithmetic to a calculator and anything with loops, large numbers or many steps to code; recognize closed forms such as n(n+1)/2 (5050 for 1 to 100).
  • The chain: parse the question, plan, call the tool with structured arguments, read the result, write the final answer. Prompting with tool descriptions and a few worked examples.
  • Guardrails: a sandbox for generated code (no network, time and memory limits), checks that the tool's output is a number of the expected type, retries on tool errors, and a cap on steps.
  • Verification: compute the answer two ways (formula and code) and compare; self-consistency over several samples.
  • Evaluation: a labeled test set split by difficulty, exact-match accuracy, tool-call error rate, latency and cost per question; regression runs on every prompt or model change.
  • Experiment tracking: prompt, model, tool versions and results logged per run.

Follow-ups

  • The model calls the calculator with a wrongly parsed expression. How do you catch it?
  • How do you handle word problems where the hard part is setting up the equation?
  • When would you fine-tune instead of prompting with tools?
  • Users ask a question with no single right answer. How does the system respond?

Where it's asked

  • Tesla · System design · Last asked Jul 202545 min · System or technical design; two rounds in senior loops

What it tests

llm · tool use · agents · langchain

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing