Ai Coding And Product Systems medium
Your code assistant's chat runs against a 2-million-line monorepo. When asked about a function, it often hallucinates the signatures of helpers defined in other files. A teammate proposes including more of the repository in the prompt. What context strategy should you adopt?
- A Concatenate the whole repository into the prompt, since giving the model every file guarantees it sees the relevant helper definitions.
- B Include only the currently open file, because adding other files dilutes attention and raises latency more than it improves answers.
- C Fine-tune the model on the repository nightly so it memorizes the helper signatures and needs no retrieved context at request time.
- D Rank candidate files by imports, symbol references, open tabs, and embedding similarity, then pack the best ones within a token budget.
Answer: D. Rank candidate files by imports, symbol references, open tabs, and embedding similarity, then pack the best ones within a token budget.
Context assembly is a **retrieval and ranking** problem: you trade the risk of missing a file for a prompt that fits the budget and stays focused. Fetching the whole repo (A) fails because it far exceeds any context window, and even partial stuffing adds cost and buries the relevant definitions. Sending only the open file (B) is fine for inline completion of self-contained code, but it starves cross-file questions.
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?