using System.Globalization;using System.Text.Json;namespace Agent.Core.ToolCalling;/// <summary>Default Agent-Core tools: current local time and date.</summary>public static class BuiltInTools{ public const string GetTimeName = "get_time"; public const string GetDateName = "get_date"; public const string ChangeNameName = "change_name"; public static void Register(ToolRegistry registry) { registry.Register(new AgentTool( GetTimeName, "Returns the current local time on this machine.", _ => DateTime.Now.ToString("T", CultureInfo.CurrentCulture))); registry.Register(new AgentTool( GetDateName, "Returns today's local date on this machine.", _ => DateTime.Now.ToString("D", CultureInfo.CurrentCulture))); registry.Register(new AgentTool( ChangeNameName, "Changes the name of the assistant.", args => { string newName = ParseName(args); if (string.IsNullOrWhiteSpace(newName)) return "Error: name cannot be empty."; registry.InvokeNameChanged(newName); return $"Success: Name changed to {newName}."; }, new { type = "object", properties = new { name = new { type = "string", description = "The new name for the assistant." } }, required = new[] { "name" } })); } private static string ParseName(string argumentsJson) { try { using var doc = JsonDocument.Parse(argumentsJson); if (doc.RootElement.TryGetProperty("name", out var nameProp)) { return nameProp.GetString()?.Trim() ?? ""; } } catch (JsonException) { } return ""; }}
Documentation
Tool calling (Version 3)
Agent-Core exposes a small tool registry for Ollama function calling. Lilith registers these tools on the chat client at boot.
| Tool | Description | |------|-------------| | get_time | Current local time | | get_date | Today's local date |
Register more tools with ToolRegistry.Register before chat starts.