Definitions returns all registered tool schemas, sorted by name so the output is deterministic (important for prompt caching when you turn it on).
()
| 51 | // Definitions returns all registered tool schemas, sorted by name so the |
| 52 | // output is deterministic (important for prompt caching when you turn it on). |
| 53 | func (r *Registry) Definitions() []api.ToolDef { |
| 54 | names := make([]string, 0, len(r.tools)) |
| 55 | for n := range r.tools { |
| 56 | names = append(names, n) |
| 57 | } |
| 58 | sort.Strings(names) |
| 59 | out := make([]api.ToolDef, 0, len(r.tools)) |
| 60 | for _, n := range names { |
| 61 | out = append(out, r.tools[n].Definition()) |
| 62 | } |
| 63 | return out |
| 64 | } |
| 65 | |
| 66 | // Execute dispatches a tool call by name. Unknown tools return an error |
| 67 | // result rather than panicking — the model can read it and recover. |