Wire it all together — a CLI agent in 12 steps — step 9 of 12
Build the tool runner. The starter has a tools dict mapping tool
names to functions. Write a function run_tool(name, args) that:
- Returns
"unknown tool"ifnameis not intools. - Otherwise calls
tools[name](args)and returns the result.
Then call run_tool("read_file", {"path": "todo.txt"}) and print
the result.
Expected output:
contents of todo.txt
⌘↵ runs the editor.read, then continue.
Build the tool runner. The starter has a tools dict mapping tool
names to functions. Write a function run_tool(name, args) that:
- Returns
"unknown tool"ifnameis not intools. - Otherwise calls
tools[name](args)and returns the result.
Then call run_tool("read_file", {"path": "todo.txt"}) and print
the result.
Expected output:
contents of todo.txt
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.