Reading and Choosing Tools Safely
Lesson 2 of 4
Choosing Among Similar Tools
Estimated time: 10 minutes
Once an agent has dozens of tools, the question stops being whether a tool exists and becomes which of several near-duplicates to use. A large flat list makes that harder, and a wrong pick carries side effects nobody asked for.
A tool's description should say how it differs from its neighbours. When two tools both read files, the one that says it reads a single file and the other that says it reads a directory is the difference that lets the model choose.
def candidates(step, tools):
need = set(step.get('needs') or [])
return [t for t in tools if need <= set(t.get('provides') or [])]
Narrow the list to the tools that fit the current step before choosing, and prefer the narrowest tool that covers the need.