> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
---
last_verified: 2026-10-09
title: Tools
description: Define Go tools with NewTool, give them a schema, register them, and let agents call them
category: Go SDK
hideRightSidebar: true
---

A tool is a function an agent can call. The model sees its name, description, and input schema, and decides when to call it. For a guided introduction, see [Tools](/docs/build/tools.md).

## `agnt5.NewTool(name, handler, opts...)`

```go
getWeather, err := agnt5.NewTool("get_weather",
	func(ctx context.Context, args map[string]any) (any, error) {
		return fmt.Sprintf("Sunny, 22°C in %v", args["city"]), nil
	},
	agnt5.WithToolDescription("Get the weather for a city"),
	agnt5.WithToolSchema(map[string]any{
		"type":       "object",
		"properties": map[string]any{"city": map[string]any{"type": "string"}},
		"required":   []any{"city"},
	}),
)
if err != nil {
	log.Fatal(err)
}
```

The handler is a `ToolHandler`: `func(context.Context, map[string]any) (any, error)`. `args` holds the arguments the model chose, and the returned value goes back to the model.

| Option | Description |
|---|---|
| `WithToolDescription(text)` | What the tool does. The model reads it to decide when to call the tool. |
| `WithToolSchema(schema)` | JSON Schema for the tool's input, as `map[string]any`. |

## Use and register a tool

Give the tool to an agent with `agnt5.WithAgentTools(getWeather)`. To run it on its own, register it with the worker:

```go
if err := agnt5.RegisterTool(worker, getWeather); err != nil {
	log.Fatal(err)
}
```

```bash
agnt5 run get_weather --type tool --input '{"city": "Paris"}'
```

## Next steps

* [Agents](/sdk/go/agents.md): run the loop that calls tools.
* [Tools guide](/docs/build/tools.md): sandbox tools, MCP tools, and asking people from a tool.
