Step-by-step hands-on tutorial on writing Python tools with @tool, configuring Granite 3 agents in YAML, and testing live via CLI.
Large Language Models (LLMs) are great at conversational synthesis, but on their own, they cannot query your company database, call an internal microservice, or run deterministic business calculations. In IBM watsonx Orchestrate (WXO), tools give your AI agents hands and feet. You can write custom logic in plain Python, decorate it with @tool, and publish it directly to your Orchestrate catalog.
greetings.py)from ibm_watsonx_orchestrate import tool
@tool
def greet_user(name: str) -> str:
"""
Generate a personalized greeting for a user.
Args:
name: The name of the person to greet.
Returns:
A friendly greeting message.
"""
return f"Hello, {name}! Welcome to IBM watsonx Orchestrate."
requirements.txt)ibm-watsonx-orchestrate>=2.9.0
agent.yaml)spec_version: v1
kind: native
name: hello_world_greeter
title: "Hello World Greeter"
description: "A friendly onboarding agent that greets users using custom Python tools."
model: ibm/granite-3-8b-instruct
instructions: |
You are a friendly and welcoming assistant.
When a user introduces themselves or asks you to greet someone, extract their name
and call the `greet_user` tool to deliver a personalized welcome.
tools:
- greet_user
orchestrate chat ask -n hello_world_greeter "Say hello to Markus"
╭─ 🤖 hello_world_greeter ───────────────────────────────────────────────╮
│ │
│ Hello, Markus! Welcome to IBM watsonx Orchestrate. │
│ │
╰────────────────────────────────────────────────────────────────────────╯
Automatically registers the function signature and docstrings into the tool JSON Schema.
Parameter types like name: str are required by Orchestrate to generate the API contract for the LLM.
Always include -r requirements.txt when importing tools via CLI.