πŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
πŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Watch a Real Agent Choose the Right Tool

Run a real multi-tool agent call and confirm correct tool selection is driven by matching the question's semantics against each tool's description.

⚑ Total XP: 0|πŸ’» langchain XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Multi-Tool Agents

Selection, not just calling.

Quick Quiz //

What actually drives a model's choice between multiple available tools?


πŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
πŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Give a model two tools and one question that only needs one of them β€” and verify it actually picks correctly, not just that tool calling works at all.

1Selection Is a Separate Skill From Calling

The previous lesson proved a model can format a correct tool call given exactly one option. This lesson tests something different and arguably more important for a real agent: given multiple plausible tools, does it pick the right one? A single-tool test can't distinguish 'the model calls tools correctly' from 'the model calls whatever tool it's given, correctly or not.'

2Descriptions Are the Actual Selection Mechanism

There's no separate routing logic choosing between tools β€” the model reads each tool's name and description text and semantically matches them against the question, the same way it would match any other text. A vague or overlapping description directly degrades selection accuracy, which is why tool descriptions deserve the same care as a well-written docstring.

3Step-by-Step Breakdown

Real agents rarely have just one tool. Give the model a list of several, and its job β€” before any Action even happens β€” is picking the right one for the question actually asked. That selection is itself a real capability worth testing directly.

Watch a Real Agent Choose the Right Tool. Two real tool schemas are attached below: get_weather and get_stock_price. The question only needs one of them. Run it and confirm the model correctly picks get_stock_price and ignores get_weather entirely β€” ​tool selection, not just tool calling.

What actually determines which tool a model chooses when given several options?

  • β†’The model matches the semantics of the user's question against each tool's name and description β€” clear, specific, distinct descriptions are what make correct selection reliable.
  • β†’The model always picks whichever tool is listed first in the tools array.

Module 5 complete: real tool calls, a real agent loop, and real multi-tool selection. Final module: the production concerns β€” streaming, observability, and evaluation β€” that separate a demo agent from a shippable one.

Level Up πŸš€

Advanced cheat sheets, SEO tricks, and interview prep for this topic.

Browser Support

ChromeSupported

Fully supported.

FirefoxSupported

Fully supported.

SafariSupported

Fully supported.

EdgeSupported

Fully supported.

Accessibility (A11y)

1Log Which Tool Was Selected, Not Just That One Was Called

When debugging agent behavior, always log the specific tool name selected (not just 'a tool call happened'), so developers reviewing logs can immediately spot incorrect selection.

logger.info(f'Agent selected tool: {tool_name}')

SEO Implications

  • 1

    Target 'LangChain agent choosing wrong tool' as an anticipated troubleshooting search

    Incorrect tool selection is a common real-world debugging scenario developers search for once they move from single-tool to multi-tool agents.

Best Practices

Write Distinct, Non-Overlapping Tool Descriptions

If two tools' descriptions are vague or semantically similar, a model has a genuinely harder time reliably choosing between them β€” invest in specific, clearly differentiated descriptions exactly as you would for any other prompt engineering task.

Frequent Bugs

THE BUG

Two tools with overlapping or vague descriptions causing the model to inconsistently pick the wrong one, or call both when only one was needed.

THE FIX

Test multi-tool selection explicitly with unambiguous questions targeting each tool, and sharpen any description that leads to incorrect or inconsistent selection.

Real-World Examples

Customer Service Agent With Multiple Tools

An agent with lookup_order, process_refund, and update_shipping_address tools correctly routes a 'where is my package' question to lookup_order and ignores the other two entirely, purely because each tool's description clearly and distinctly signals its purpose.

tools = [lookup_order, process_refund, update_shipping_address]

Interview Prep

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Hardcoding sensitive credentials

// Wrong const API_KEY = 'sk-123456789'; // Correct const API_KEY = process.env.API_KEY;

The Solution //

Never hardcode API keys, passwords, or secrets in your source code. Use environment variables (.env files) to keep them secure and out of version control.

Lesson Glossary

[01]Tool Selection

A model's process of matching a question's intent against multiple available tools' names and descriptions to choose the correct one.

Code Preview
model picks: get_stock_price, not get_weather

Continue Learning