Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Principle:CrewAIInc CrewAI Tool Design

From Leeroopedia

Overview

A design pattern for specifying tool interfaces through a name, natural language description, and a typed argument schema that enables LLM-driven tool selection and invocation.

Description

Tool Design establishes how tools are presented to language models for function calling. Each tool has a unique name, a description that tells the LLM when, how, and why to use it, and a Pydantic-based argument schema that defines accepted inputs with types and descriptions. The LLM uses these specifications to decide which tool to call and how to construct the arguments. Good tool design is critical for reliable agent behavior.

The three components of a well-designed tool are:

  • Name: A short, unique identifier that the LLM uses to reference the tool. Names should be descriptive and follow a consistent naming convention (e.g., search_web, read_file).
  • Description: A natural language explanation of the tool's purpose, expected behavior, and usage constraints. The LLM relies on this text to decide when to invoke the tool. Vague or misleading descriptions lead to incorrect tool selection.
  • Args Schema: A Pydantic model that declares each argument's name, type, default value, and description. This typed schema enables the LLM to construct valid invocation payloads and allows the framework to validate inputs before execution.

Together, these three elements form a tool specification that is serialized into the LLM's function-calling interface. The quality of these specifications directly determines how accurately and reliably an agent selects and invokes tools.

Key Considerations

  • Descriptions should be action-oriented: Describe what the tool does and when to use it, not just what it is. For example, "Search the web for current information about a topic" is better than "Web search tool."
  • Argument types must be explicit: Use Python type annotations (str, int, list[str]) so the LLM can generate correctly typed arguments.
  • Field descriptions are critical: Each argument in the schema should have a Field(description=...) so the LLM understands what value to provide.
  • Unique names prevent ambiguity: If two tools share a name, the LLM cannot distinguish between them. Tools must have globally unique names within an agent's tool set.
  • Keep schemas minimal: Only require arguments the tool genuinely needs. Optional arguments should have sensible defaults.

Theoretical Basis

This principle is grounded in the Function Calling / Tool Use paradigm in large language models. In this paradigm, tools are represented as typed function signatures with natural language documentation. The LLM is trained to select from available functions and produce structured argument payloads that conform to declared schemas. The effectiveness of this paradigm depends on clear, accurate, and complete tool specifications.

This aligns with the broader concept of interface contracts in software engineering, where the quality of an interface definition determines how correctly consumers (in this case, the LLM) can interact with a component (the tool).

Relationship to Implementation

Implementation:CrewAIInc_CrewAI_BaseTool_Schema

The BaseTool class in CrewAI provides the concrete interface for defining tool specifications. It exposes name, description, and args_schema fields that directly map to the three components described in this principle.

See Also

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment