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:
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:
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
| Registration | Model can request it | Studio tool registry |
|---|---|---|
agent.AddTool<TextStatsTool>(), then register the agent | For that agent | Included |
options.AddTool<TextStatsTool>() | Only if separately attached to an agent | Included |
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.