Tutorials Agentic AI with .NET Tutorial
Native Functions as Tools
Native Functions as Tools: free step-by-step lesson with examples, common mistakes, and interview tips — part of Agentic AI with .NET Tutorial on Toolliyo Academy.
On this page
Agentic AI with .NET Tutorial · Lesson 14 of 120
Native Functions as Tools
Foundations & SK → Tools & RAG → Product & Ops → Projects
Foundations & SK · 1 — Agent basics · ~6 min · Semantic Kernel
What is this?
Native functions are C# methods you expose to the model as tools. The model proposes a call; your code runs the method and returns a result.
Why should you care?
This is how agents fetch orders, create tickets, or search docs without inventing data.
See it live — copy this example
Use .NET 8+. Run Semantic Kernel samples in a console or Web API. Keep API keys in user secrets or environment variables — never in source.
using System.ComponentModel;
using Microsoft.SemanticKernel;
public class OrdersPlugin
{
[KernelFunction, Description("Get order status by id")]
public string GetStatus([Description("Order id")] string orderId)
=> $"Order {orderId}: Shipped"; // replace with real service
}
// builder.Plugins.AddFromType<OrdersPlugin>();
What happened?
- KernelFunction marks a tool.
- Description helps the model choose it.
- You still enforce auth in the method body.
Practice next
- Add OrdersPlugin to a kernel.
- Invoke the function directly from C# first.
- Then let a prompt request the status.
- Add GetCustomerOrders(customerId).
- Return a short summary string only.
Remember
Native functions = real C# tools. Descriptions guide tool choice. Validate inputs in code.
Order tool
Support agent must not invent shipment status.
Outcome: Status comes from GetStatus only.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!