ToolsAttaching tools
TOOLS

Attaching tools

Choose which agents can request a tool and which tools can be tested directly.

Use the TextStatsTool from Defining tools. Registration determines tool availability; application authorization remains part of the operation.

Attach to the Support Agent

In Program.cs, register the agent and its tool before building the host:

Program.cs
using Runiq.AI.Agents;
using Runiq.AI.Agents.Tools;
using Runiq.AI.Core;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRuniqServer(options =>
{
    options.AddAgent(new Agent(
        id: "support-agent",
        name: "Support Agent",
        instructions: """
            Help users understand the application.
            Use text_stats when asked to count characters or words.
            Report the returned counts without guessing.
            """,
        model: "openai/gpt-5",
        apiKey: builder.Configuration["OpenAI:ApiKey"])
        .AddTool<TextStatsTool>());
});

var app = builder.Build();

app.Run();

Configure the model connection before sending an agent request. The tool itself has no provider dependency.

Register for direct testing

To register the tool without attaching it to any agent, use this registration instead:

Program.cs
builder.Services.AddRuniqServer(options =>
{
    options.AddTool<TextStatsTool>();
});

Choose one host registration block and compose the required definitions inside it. A standalone registration appears in the tool registry but does not make the tool available to every agent.

Compare the two paths

RegistrationModel can request itStudio tool registry
agent.AddTool<TextStatsTool>(), then register the agentFor that agentIncluded
options.AddTool<TextStatsTool>()Only if separately attached to an agentIncluded

Attached tools are already included in the host tool registry. They do not need an additional standalone registration just to appear in Studio.

Keep access rules in application code

Tool attachment limits the model's available operations. It does not check the current user's permissions or authorize access to a particular record.

Apply those checks in the tool or its underlying service. Standalone Studio execution can invoke the operation directly, so the operation must enforce its rules regardless of the caller.

Next: Test the tool in Studio →

On this page