AI Agents by HandAll problemsAbout

All problems › Python drill · easy · ~4 min

d04 · Log tool calls

mutable defaults copies

Solve it in your browser →

d04 · Log tool calls (~4 min)

Mutation and references. Edit drills.py. Standard library only; no model calls, no API key.

def log_call(name, tool_input, log=None):

Append {"name": name, "input": tool_input} to log and return log.

When log isn't passed, start a new empty list on every call. The logged input must not change if the caller later mutates its tool_input (including nested values).

Failure messages are enough to go on, so leave the tests unread until you submit.

Starter code and hidden tests open in the editor. Nothing to install.