promptdojo_

Multi-step tools — when one tool isn't enough — step 6 of 9

The model hallucinated a tool name — web_search — that isn't in the registry. The current dispatch raises KeyError deep inside the loop, which crashes the agent and loses the whole conversation.

Fix the dispatch so an unknown tool returns the string "unknown tool: <name>" as the tool result instead. The model can then read that and recover (it usually retries with a real tool name).

Expected output:

unknown tool: web_search
The break is on line 12 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.