Ai Coding And Product Systems hard
Your code assistant serves inline completions and chat from the same mid-size model cluster. Completion p95 is 900 ms end to end, and acceptance rate drops sharply above about 400 ms. Chat users are happy with multi-second responses. What is the best architectural change for completions?
- A Keep the mid-size model but stream ghost text token by token, since users perceive the suggestion as instant once the first characters render.
- B Route completions to a dedicated small code model pool with prefix caching of file context, accepting weaker multi-line suggestions.
- C Expand context to the whole repository so suggestions are accepted more often, amortizing the latency cost across fewer total requests.
- D Keep one shared large model for chat and completion, but give completion requests strict priority in the batch scheduler to remove queueing.
Answer: B. Route completions to a dedicated small code model pool with prefix caching of file context, accepting weaker multi-line suggestions.
Completion and chat are different surfaces. Completion needs roughly 200 to 400 ms, which forces a **small model plus aggressive caching**, and the cost is weaker long suggestions. Prioritizing completions in a shared scheduler (D) removes queueing but not the prefill and decode time of a bigger model, which alone breaks the budget. A shared model only works when every surface tolerates chat-class latency.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Your assistant uses a classifier to route queries to a small or large model, which saves 60% of GPU spend. Analysis shows about 20% of hard queries are misrouted to the small model, which then gives confident wrong answers, and regenerate clicks on those threads have doubled. What should you do?
- Your workspace AI retrieves the top-k chunks from a shared vector index and passes them to the model with ACL metadata and a system prompt saying 'only use documents this user can access.' A user just received an answer quoting a private HR page they cannot open. What is the correct fix?
- Your support bot answers billing questions. One user has asked the same refund question three times, and retrieval confidence for that topic is low. What should the bot do next?
- Your AI review system receives a 4,000-line pull request spanning 60 files. Sending the whole diff in one prompt yields shallow, generic comments, and real bugs in files near the middle of the diff are missed. How should you structure the review?
- In your ChatGPT-style assistant, power users keep single threads running for weeks, reaching about 150K tokens. Cost per turn keeps climbing, latency is rising, and the model increasingly misses facts from early in the thread. What should you do?
- Your workspace AI filters retrieval using ACLs stored in the vector index, which is rebuilt nightly. An admin removes an employee from a confidential project page, but for the rest of the day the employee can still get AI answers drawn from it. What is the right fix?