-
-
Notifications
You must be signed in to change notification settings - Fork 4
CommonTools
Agent Framework Toolkit includes a provider-independent set of commonly useful tools in the AgentFrameworkToolkit.Tools.Common namespace.
Note
These tools are regular AITool instances and can be used with both Agent Framework Toolkit agents and plain AIAgent instances from Microsoft Agent Framework.
dotnet add package AgentFrameworkToolkit.Tools
using AgentFrameworkToolkit.OpenAI;
using AgentFrameworkToolkit.Tools;
using AgentFrameworkToolkit.Tools.Common;
OpenAIAgentFactory agentFactory = new("<apiKey>");
AIToolsFactory toolsFactory = new();
OpenAIAgent agent = agentFactory.CreateAgent(new AgentOptions
{
Model = "gpt-5",
Instructions = "Use tools when helpful.",
Tools =
[
..toolsFactory.GetTimeTools(),
..toolsFactory.GetWebsiteTools(),
..toolsFactory.GetHttpClientTools()
]
});File system tools include both read and write operations. If you enable them, you should typically confine them to specific folders.
- Read:
get_content_of_file,get_files,get_folders,file_exists,folder_exists - Write:
create_file,create_folder,move_file,delete_file,delete_folder,copy_file,copy_folder
If you set FileSystemToolsOptions.ConfinedToTheseFolderPaths, every operation will be validated to ensure it stays within one of those folder paths (including subfolders). If you do not set it, no confinement is applied.
using AgentFrameworkToolkit.Tools;
using AgentFrameworkToolkit.Tools.Common;
AIToolsFactory toolsFactory = new();
IList<AITool> tools = toolsFactory.GetFileSystemTools(new GetFileSystemToolsOptions
{
FileSystemToolsOptions = new FileSystemToolsOptions
{
ConfinedToTheseFolderPaths = ["C:\\data\\agent-workdir"]
}
});HTTP tools provide simple GET/POST/PUT/PATCH/DELETE/HEAD helpers that return a formatted response string.
http_get, http_post, http_put, http_patch, http_delete, http_head
-
HttpClientToolsOptions.IncludeHeaders(default:false) -
HttpClientToolsOptions.ThrowOnError(default:false) -
HttpClientToolsOptions.HttpClientFactory(optional)
AIToolsFactory toolsFactory = new();
IList<AITool> tools = toolsFactory.GetHttpClientTools(new GetHttpClientToolsOptions
{
HttpClientToolsOptions = new HttpClientToolsOptions { IncludeHeaders = true }
});Time tools provide current time in UTC and local time. Local time can optionally accept a timeZoneId parameter (Windows/ICU timezone ids supported by .NET).
get_now_local, get_now_utc
AIToolsFactory toolsFactory = new();
IList<AITool> tools = toolsFactory.GetTimeTools(new GetTimeToolsOptions
{
GetNowLocalOptions = new GetNowLocalOptions
{
IncludeTimezoneParameter = true,
DefaultLocalTimezoneIdIfNoneIsProvided = "UTC"
}
});Weather tools use the OpenWeatherMap API and require an API key.
get_weather_for_city
AIToolsFactory toolsFactory = new();
IList<AITool> tools = toolsFactory.GetWeatherTools(new OpenWeatherMapOptions
{
ApiKey = "<openweathermap-api-key>",
PreferredUnits = WeatherOptionsUnits.Metric
});Website tools fetch the content of a page from a URL, optionally stripping HTML/JS/CSS and returning plain text.
get_content_of_url
AIToolsFactory toolsFactory = new();
IList<AITool> tools = toolsFactory.GetWebsiteTools(new GetWebsiteToolsOptions
{
GetContentOfPageOptions = new GetContentOfPageOptions { StripMarkup = true }
});