1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →
FDE live-coding round: "Build a minimal tool-calling agent in 45 minutes." What do you build, and what do interviewers look for?
30-second answerSay your answer out loud first, then reveal.
Skeleton
Provider-agnostic Python; adapt to the SDK in use:
import json
TOOLS = {
"get_order_status": {
"description": "Get status of an order by order_id (e.g. 'ORD-123').",
"parameters": {"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
"fn": lambda order_id: {"order_id": order_id, "status": "shipped"},
},
}
def run_tool(name, args):
if name not in TOOLS:
return {"error": f"Unknown tool '{name}'"}
try:
return TOOLS[name]["fn"](**args)
except TypeError as e: # bad / missing arguments
return {"error": f"Invalid arguments: {e}"}
def agent(user_msg, llm, max_steps=8):
messages = [{"role": "system", "content": "You are a support agent. Use tools; never invent order data."},
{"role": "user", "content": user_msg}]
schemas = [{"name": n, "description": t["description"], "parameters": t["parameters"]}
for n, t in TOOLS.items()]
for step in range(max_steps):
reply = llm.chat(messages=messages, tools=schemas) # wrapper over your provider SDK
messages.append(reply.as_message())
if not reply.tool_calls:
return reply.text # final answer
for call in reply.tool_calls:
result = run_tool(call.name, call.arguments)
print(json.dumps({"step": step, "tool": call.name, "args": call.arguments, "result": result}))
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
return "I couldn't complete this within the step limit. Here is what I found so far..."What to narrate and add if time permits
- Why tool errors are returned to the model (so it can self-correct) rather than raised.
- A max-steps guard and graceful failure message.
- Argument validation against the schema (e.g. with Pydantic).
- Logging per step (trace-like) for debugging.
- A quick test with a fake LLM that returns scripted tool calls (deterministic tests).
- Next steps you'd take: retries and backoff, auth scoping, HITL for risky tools, evals.
Common mistakes
- Spending 20 minutes on framework setup.
- No error handling.
- No stopping condition.
- Silent debugging without talking.
Related
You understood something today that you didn't yesterday.