# AgentParameterValidator

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.agentparametervalidator/
> Summary: AgentParameterValidator: Validates an AgentDefinition's parameter schema, and validates a run's supplied values against it.

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Core.dll</code></div>

Validates an [AgentDefinition](/api/tracon.agentdefinition/)'s parameter schema, and validates
a run's supplied values against it.

```csharp
public static class AgentParameterValidator
```

<dl class="api-relations"><dt>Inheritance</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object">object</a> ← <a href="/api/tracon.agentparametervalidator/">AgentParameterValidator</a></dd><dt>Inherited Members</dt><dd><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object?, object?)</a>, <a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a></dd></dl>

## Remarks

Two independent checks live here, run at two different times:

- [AgentParameterValidator.ValidateSchema](/api/tracon.agentparametervalidator/#Tracon_AgentParameterValidator_ValidateSchema_Tracon_AgentDefinition_) - compile-time self-consistency of the schema against the instructions text. Runs inside [AgentDefinitionCompiler](/api/tracon.agentdefinitioncompiler/), so `POST /api/agents`, `PUT /api/agents/{name}`, and `POST /api/agents/validate` all inherit it through the compile step they already run.
- [AgentParameterValidator.ValidateValues](/api/tracon.agentparametervalidator/#Tracon_AgentParameterValidator_ValidateValues_System_Collections_Generic_IReadOnlyList_Tracon_AgentParameter__System_Collections_Generic_IReadOnlyDictionary_System_String_System_String__System_Nullable_System_Int32__) - run-time check of a request's parameter values against the schema. `POST /api/agents/{name}/run` and `POST /api/agents/{name}/estimate` both call this **same** method, so a missing or unknown parameter produces the identical error on both endpoints.

## Fields

### <a id="Tracon_AgentParameterValidator_MissingParameterCode"></a> MissingParameterCode

Error code: a required parameter has neither a supplied value nor a default.

```csharp
public const string MissingParameterCode = "missing_parameter"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_AgentParameterValidator_UnknownParameterCode"></a> UnknownParameterCode

Error code: a supplied value's name is not declared in the schema.

```csharp
public const string UnknownParameterCode = "unknown_parameter"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="Tracon_AgentParameterValidator_ValueTooLongCode"></a> ValueTooLongCode

Error code: a supplied value exceeds the configured maximum length.

```csharp
public const string ValueTooLongCode = "value_too_long"
```

#### Field Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Methods

### <a id="Tracon_AgentParameterValidator_ValidateSchema_Tracon_AgentDefinition_"></a> ValidateSchema\(AgentDefinition\)

Checks a definition's parameter schema against its own instructions text.

```csharp
public static IReadOnlyList<string> ValidateSchema(AgentDefinition definition)
```

#### Parameters

`definition` [AgentDefinition](/api/tracon.agentdefinition/)

The definition being compiled.

#### Returns

 [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\>

One message per violation; empty when the schema is self-consistent. A
definition with an empty [AgentDefinition.Parameters](/api/tracon.agentdefinition/#Tracon_AgentDefinition_Parameters) list
is never checked against its text - `{{...}}` is plain text for an
agent that declares no parameters at all, and stays that way (no
surprise for the agents that never opt into this feature).

### <a id="Tracon_AgentParameterValidator_ValidateValues_System_Collections_Generic_IReadOnlyList_Tracon_AgentParameter__System_Collections_Generic_IReadOnlyDictionary_System_String_System_String__System_Nullable_System_Int32__"></a> ValidateValues\(IReadOnlyList<AgentParameter\>, IReadOnlyDictionary<string, string\>?, int?\)

Checks a run's supplied parameter values against a definition's schema.

```csharp
public static AgentParameterValidationResult ValidateValues(IReadOnlyList<AgentParameter> schema, IReadOnlyDictionary<string, string>? values, int? maxValueLength = null)
```

#### Parameters

`schema` [IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[AgentParameter](/api/tracon.agentparameter/)\>

The target agent's parameter schema.

`values` [IReadOnlyDictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>?

The values a run request supplied. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) means none.

`maxValueLength` [int](https://learn.microsoft.com/dotnet/api/system.int32)?

The largest UTF-8 byte count a supplied value may have. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) means no limit
(the default, kept for a caller that predates this check).

#### Returns

 [AgentParameterValidationResult](/api/tracon.agentparametervalidationresult/)

The validation outcome.

#### Exceptions

 [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception)

`schema` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null).
