Tool Declarations
[Preview] -- Tool declarations are part of the agent system currently in development.
Tools bridge agents to your domain logic. A tool declaration defines the input contract, output contract, and the operation to perform -- typically wrapping a Grove action, query, or external service call.
Prerequisites: Agent Declarations. What you'll learn: How to declare tools that agents can invoke.
Tool Declaration
tool lookup_order {
description "Look up an order by ID and return its current status"
input {
order_id: Id
}
output {
order_id: Id
status: String
items: List<OrderItem>
total: Decimal
}
data result {
query orders.get_by_id {
id: input.order_id
}
}
apply {
return {
order_id: result.id,
status: result.status,
items: result.items,
total: result.total
}
}
}
Fields
| Field | Required | Description |
|---|---|---|
description | Yes | Human-readable description (used by the LLM to decide when to use the tool) |
input | Yes | Input fields with types |
output | No | Output fields with types (if the tool returns data) |
data | No | Data blocks for fetching/invoking operations |
apply | No | Transform logic for the result |
Wrapping Actions
Tools can invoke Grove actions directly:
tool process_return {
description "Process a return for an order item"
input {
order_id: Id
item_id: Id
reason: String
}
output {
return_id: Id
status: String
}
data result {
invoke returns.create {
order_id: input.order_id
item_id: input.item_id
reason: input.reason
}
}
apply {
return {
return_id: result.id,
status: "initiated"
}
}
}
Wrapping External Services
Tools can also call external services:
tool search_products {
description "Search the product catalog by keyword"
input {
query: String
max_results: Int = 10
}
output {
products: List<ProductSummary>
}
data results {
fetch catalog.search {
q: input.query
limit: input.max_results
}
}
apply {
return { products: results.items }
}
}
See Also
- Agent Declarations -- Define agents that use tools
- MCP Server -- Expose tools via MCP protocol
- Activities -- Similar data block patterns