0Pricing
AI Agents with LangChain & Autonomous Workflows · Aula

Kits de ferramentas e entradas estruturadas

Agrupe ferramentas relacionadas em kits reutilizáveis e defina argumentos estruturados e tipados com esquemas para que os agentes chamem suas ferramentas de forma confiável, com os parâmetros corretos.

Kits de ferramentas e entradas estruturadas é uma aula grátis de AI Agents with LangChain & Autonomous Workflows no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de AI Agents with LangChain & Autonomous Workflows, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de AI Agents with LangChain & Autonomous Workflows inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Beyond Single Tools

Real integrations rarely need just one function. A database integration needs list-tables, run-query, and describe-schema together.

A toolkit groups related tools so an agent gets a coherent capability in one bundle.

The Single-String Limitation

A basic tool takes one string input. But many actions need multiple typed arguments — a date range, a user id, a limit.

Structured tools let the agent pass several validated parameters instead of cramming them into one string.

Defining an Input Schema

Use a Pydantic model to describe the arguments. The field descriptions guide the LLM on how to fill them.

from pydantic import BaseModel, Field

class SearchArgs(BaseModel):
    query: str = Field(description='Search keywords')
    limit: int = Field(description='Max results', default=5)

Attaching the Schema to a Tool

Pass args_schema so the agent knows the exact shape it must produce.

from langchain.tools import StructuredTool

def search(query: str, limit: int = 5):
    return run_search(query, limit)

tool = StructuredTool.from_function(
    func=search,
    name='search',
    description='Search the catalog',
    args_schema=SearchArgs
)

The @tool Decorator Shortcut

The @tool decorator infers a schema from your type hints and docstring, the quickest way to make a structured tool.

from langchain.tools import tool

@tool
def get_weather(city: str, units: str = 'metric') -> str:
    'Get current weather for a city.'
    return fetch_weather(city, units)

Why Descriptions Matter

The LLM chooses tools and fills arguments from your name and descriptions. Vague text causes wrong tool choice or bad parameters.

  • Say what the tool does and when to use it
  • Describe each field clearly
  • Mention units and formats

Building a Toolkit

A toolkit subclass exposes a get_tools() method returning the grouped tools. Shared config (like a client) lives on the toolkit.

from langchain.tools import BaseToolkit

class CrmToolkit(BaseToolkit):
    client: object
    def get_tools(self):
        return [list_contacts, create_contact, add_note]

Giving Tools to an Agent

Expand a toolkit into the agent's tool list. The agent now has the whole capability set at once.

toolkit = CrmToolkit(client=crm)
agent = create_agent(llm, toolkit.get_tools())

Validation Protects You

Because the schema is enforced, malformed agent output is rejected before your function runs. This stops invalid types or missing required fields from reaching your integration.

Handling Tool Errors

Tools can fail (network, bad input). Catch exceptions and return a helpful message so the agent can recover or ask the user, instead of crashing the run.

@tool
def fetch_order(order_id: str) -> str:
    'Look up an order by id.'
    try:
        return api.get(order_id)
    except NotFound:
        return 'No order found with that id.'

Reusability

Toolkits make integrations portable: build a GitHubToolkit once and drop it into any agent. Combine multiple toolkits to give an agent broad, well-defined powers.

Quick Check

Test your tools knowledge.

Recap

You learned to build robust integrations:

  • Structured tools accept multiple typed arguments via an args_schema
  • The @tool decorator infers schemas from hints
  • Clear descriptions drive correct tool use
  • Toolkits bundle related tools for reuse
  • Validation and error handling keep agents stable

Well-structured tools are the backbone of dependable agent integrations.

Perguntas Frequentes

A aula “Kits de ferramentas e entradas estruturadas” é grátis?

Sim — o texto completo de “Kits de ferramentas e entradas estruturadas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de AI Agents with LangChain & Autonomous Workflows, atualize para CoddyKit PRO. O curso de AI Agents with LangChain & Autonomous Workflows inclui 4 aulas no total.

O que vou aprender em “Kits de ferramentas e entradas estruturadas”?

Agrupe ferramentas relacionadas em kits reutilizáveis e defina argumentos estruturados e tipados com esquemas para que os agentes chamem suas ferramentas de forma confiável, com os parâmetros correto… Você pratica AI Agents with LangChain & Autonomous Workflows com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar AI Agents with LangChain & Autonomous Workflows?

Nenhuma experiência prévia é necessária. AI Agents with LangChain & Autonomous Workflows no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Kits de ferramentas e entradas estruturadas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de AI Agents with LangChain & Autonomous Workflows?

Sim. Cada aula de AI Agents with LangChain & Autonomous Workflows inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Criando ferramentas personalizadas do LangChain
  2. Integrando APIs externas
  3. Extração de dados da web e enriquecimento de dados
  4. Kits de ferramentas e entradas estruturadas
← Voltar para AI Agents with LangChain & Autonomous Workflows