Components

Let the model call your code.

SmartTools are the methods you allow the AI to invoke. They are how an assistant stops merely answering and starts acting — reading the open record, calling an API, asking the user a question, opening a screen. And because a tool is just one of your methods, it runs with your validation, your permissions and your business rules around it.

This is the deep integration that the Wisej.NET architecture makes uniquely possible: the same process holds your UI, your data and your AI, so a tool can touch all three directly — no bridge service, no serialization layer in between.

One attribute makes a tool

Mark any method with [SmartTool.Tool] and add a [Description] so the model knows when it applies. The method signature tells the model what arguments to produce; the description tells it what the tool is for. There is no JSON schema to author and keep in sync — plain .NET parameters and return values are enough.

  • [SmartTool.Tool] marks the method the model may call.
  • [Description] on the method and each parameter guides the model.
  • Return values flow straight back into the conversation.
  • Descriptions can be inlined or pulled from an /AI resource file.
csharp
// Any method becomes a tool with one attribute
[SmartTool.Tool]
[Description("Returns the ID of the report currently open.")]
public string GetCurrentReportId() =>
    ((IncidentReportPage)Application.MainPage).GetReportId();

Scope

Attach a tool exactly where it belongs.

A tool's reach is decided by where you attach it. A SmartHub automatically registers every [SmartTool.Tool] method in its container, and you can scope others more tightly — so the model is offered just the tools that make sense for the task in front of it.

SmartHub

Shared by every adapter on the screen. Drop a method in the hub's container and it is available to the whole assistant.

SmartAdapter

Scoped to one control's adapter — a tool only that adapter, and the model talking to it, can reach.

SmartSession

Lives for the length of the user's session, so state gathered earlier stays callable later on.

SmartPrompt

Available only inside a single prompt's context — a tool that exists for one question and then is gone.

Registered for you, or by you

Point a SmartHub at a container and it discovers every decorated method automatically — nothing to wire. When you want to be explicit, UseTool and UseTools add methods from anywhere, and they are fluently chainable. Either way, the surface the AI can touch is exactly the surface you chose to expose.

How the hub binds endpoint, adapters and tools →

csharp
// A SmartHub auto-registers every [SmartTool.Tool] in its container
var hub = new SmartHub(this) {
    Endpoint = new OpenAIEndpoint { Model = "gpt-4o" }
};

// Or register one explicitly — fluent and chainable
hub.UseTool(GetCurrentReportId);

Built-in tools you get for free

You write tools for your own application, but you rarely start from nothing. Several SmartAdapters ship with their own built-in tools — ready-made methods that already know how to drive the control they front. Drop the adapter in and its tools are registered with it; the model can work the control immediately, with nothing for you to wire.

The SmartChartJS3Adapter, for instance, carries ChartJS3Tools to build and populate a chart from a plain-language request. And because a built-in tool is just an ordinary SmartTool, swapping it retargets the same adapter at another charting library — DevExpress, Syncfusion, Telerik — without touching the rest of your assistant.

See all built-in SmartTools ↗

csharp
// Some adapters bring their own tools — registered with the adapter
var chart = new SmartChartJS3Adapter { Chart = chartJS1 };

// ChartJS3Tools is built in, so this just works:
await chart.RunAsync(
    "Show the split of sales by channel as a bar chart");

What a tool can reach

From a single method, the whole stack.

Because a tool is ordinary .NET code running inside your application, it can reach far beyond the model — into the app itself, out to the network, down to the browser, across to the user, and over to other AI systems.

Your application

Read the running app and drive it: the open record, the current selection, a screen to launch. Your code is the API.

External APIs

Call any REST service or SDK. Tools can be async, so the agent waits on a forecast or a lookup without blocking a thread.

The browser

Evaluate JavaScript on the client or raise a native prompt, then push the result back with Application.Update.

The UI

Open a dialog and wait for the user to choose before answering — a human step in the middle of an AI action.

Other models

Hand a sub-task to another provider, model or framework such as Semantic Kernel, all from inside one tool.

Tools that talk to the world

A tool can be async, so the agent can call a REST API and "wait" for the answer without ever blocking a thread. The model decides it needs the data and requests the call; your method does the work and hands a typed result back into the conversation.

csharp
// Tools can be async — the agent waits without blocking a thread
[SmartTool.Tool]
[Description("Gets the current forecast for a set of coordinates.")]
public async Task<string> GetWeather(float latitude, float longitude)
{
    var client = new HttpClient();
    var url = $"https://api.weather.gov/points/{latitude},{longitude}";
    var response = await client.GetAsync(url);
    return await response.Content.ReadAsStringAsync();
}

Tools that ask the user

One of the most powerful patterns: a tool can open a dialog, pause for a human decision, and only then return. The AI action and the user's judgement meet in the same step — perfect for confirmations, disambiguation or picking the record to act on.

csharp
// A tool can open a dialog and wait for the user before answering
[SmartTool.Tool]
[Description("Asks the user to pick the customer to analyze.")]
public async Task<string[]> GetCustomerSalesAsync()
{
    var dlg = new PickCustomerDialog();
    if (await dlg.ShowDialogAsync() == DialogResult.OK)
        return LoadSalesRecords(dlg.CustomerId).ToArray();

    return null;
}

AI on your terms

The model can only do what your tools allow.

There is no hidden access. The assistant cannot reach into your application except through the methods you decorate — and inside each one, your code still validates, authorizes and decides. SmartTools are why a Wisej.AI copilot can be trusted to act: the boundary of what it can touch is a boundary you wrote.