Table of Contents

Class LMFunctionToolBinder

Namespace
LMKit.Agents.Tools
Assembly
LM-Kit.NET.dll

Discovers methods annotated with LMFunctionAttribute and binds them to ITool adapters.

This type is stateless: each call inspects the provided instance/type/assembly via reflection, validates parameter types, and returns newly constructed ITool instances.

public static class LMFunctionToolBinder
Inheritance
LMFunctionToolBinder
Inherited Members

Examples

Binding annotated methods on an instance to ITool adapters:

using LMKit.Agents.Tools;

public sealed class MathTools { [LMFunction("add", "Adds two integers and returns the sum.")] public int Add(int a, int b) => a + b; }

var tools = LMFunctionToolBinder.Bind(new MathTools()); foreach (ITool tool in tools) Console.WriteLine(tool.Name);

Remarks

  • Only instance, public, non-abstract, non-generic methods are considered.
  • Parameters must use types supported by LM-Kit tool arguments (e.g., string, enums, and primitive numeric/boolean types). Unsupported types trigger ArgumentException.
  • If present, DescriptionAttribute on parameters is surfaced into the generated JSON schema.
  • Tool names and descriptions are taken from Name and Description.

Methods

FromAssembly(Assembly)

Creates ITool instances from all types in the given assembly that expose instance methods annotated with LMFunctionAttribute.

FromInstance(object)

Creates ITool instances from all LMFunctionAttribute methods on the given instance.

FromMethod(object, MethodInfo)

Creates a single ITool from a specific method on the supplied instance.

FromType(Type)

Creates ITool instances from all LMFunctionAttribute methods on the specified type.

FromType<T>()

Creates ITool instances from all LMFunctionAttribute methods on T.

Share