Mid-level interview questionAsked at Grammarly · interview write-up
Design an AI chat for a spreadsheet product that turns commands like sum column K or delete row 5 into validated tool calls on the sheet.
Model answer
Give the model a few typed tools, like sum a range or delete rows, plus a compact view of the sheet: headers, size, a few rows.
Scroll sideways to see the whole diagram
The context holds the tool definitions and the user's question.
Text version
- The context holds the tool definitions and the user's question.
- The model emits a structured call: a tool name and JSON arguments. With Anthropic's API the reply stops with stop_reason "tool_use".
- The call is text the model generated. Your code checks it before anything runs.
- Your code executes the function. The model has no hands: it only asked.
- The output goes back into the context (a tool_result block) and the model runs again, until it answers instead of calling.
After AI Engineering, Ch. 6 "Function calling", and Anthropic, "Tool use with Claude" (fetched 2026-10-21). Illustrative call.
It emits a tool call; your code validates it against the schema and the live sheet, checking column K exists and row 5 is in range, then executes. Destructive actions show a preview and need confirmation, and everything is undoable. Evaluate on commands with expected calls.
Practise the rest
8 Tools & constraints questions, 492 in all, each with a model answer. Free.
More from Grammarly interview questions.
More Tools & constraints interview questions
- In tool calling, who executes the tool, and what does the model need in order to use the result?
- The model keeps calling search_orders for refund questions that another tool handles. What do you change first?
- Explain one step of constrained sampling. What does it guarantee, and what doesn't it?
- Your agent has a delete_records tool. What has to happen between the model emitting a call and the delete running?
- Should you turn on grammar-constrained decoding for every structured output? What would you watch?
- Implement a client that spreads LLM calls across several providers, respecting their rate limits and failing over when one is down.