Configure A Harness Per Run
AgentRunConfig.Harnesses changes only declared execution settings for one run. The partial override is captured before asynchronous execution and cannot change the agent's definition.
JSON Or YAML
harnesses:
- name: SearchHarness
config:
maxResults: 5{
"harnesses": [
{
"name": "SearchHarness",
"config": {
"maxResults": 5
}
}
]
}A run override names the harness by its exact activation identity or by its class name when that name is unique among the agent's selected harnesses.
Supplying maxResults preserves every other agent setting:
Agent endpoint = https://search.internal
Agent maxResults = 20
Run maxResults = 5
Effective endpoint = https://search.internal
Effective maxResults = 5Only properties marked [RunOverridable] can be supplied. Construction-only properties fail before execution:
HarnessRunOverrideNotSupported
harnesses[0].config.endpoint
This setting is construction-only.Typed C#
The generator emits a presence-aware override type from the settings contract:
var runConfig = new AgentRunConfig();
runConfig.Harnesses
.For<SearchHarness>()
.Override(new SearchConfigOverrides
{
MaxResults = 5
});
await runtime.RunAsync(
"Find the API documentation",
runConfig: runConfig);Omitted wrapper properties mean “preserve the agent value.” They do not overwrite the setting with the property type’s default.
Patch Rules
| Input | Result |
|---|---|
| Property omitted | Preserve the resolved value |
| Explicit value | Replace that property |
| Explicit null | Assign null only when the setting permits it |
| Nested object | Patch supplied child properties |
| Collection or dictionary | Replace the complete value |
| Reset | Restore the library default |
Unknown fields, duplicate fields, and incorrect case fail with the configuration path.
Reset To Library Default
harnesses:
- name: SearchHarness
resets:
- /maxResultsTyped equivalent:
runConfig.Harnesses
.For<SearchHarness>()
.Override(
new SearchConfigOverrides(),
"/maxResults");A reset restores the library default, not the agent setting:
Library default = 10
Agent setting = 20
Run reset = /maxResults
Effective run = 10Reset pointers use RFC 6901 syntax. A reset cannot overlap a supplied value or another reset on the same path or an ancestor/descendant path.
Middleware
Middleware a harness declares is patched inside that harness entry, by identity:
harnesses:
- name: DatabaseHarness
config:
middlewares:
- name: rateLimit
config:
requestsPerMinute: 5runConfig.Harnesses.For<DatabaseHarness>().Middleware<RateLimitMiddleware>()
.Override(new RateLimitConfigOverrides { RequestsPerMinute = 5 });Global middleware uses a top-level middlewares list with the same entry shape and rules:
runConfig.Middlewares.For<RateLimitMiddleware>()
.Override(new RateLimitConfigOverrides { RequestsPerMinute = 20 });The middleware instance is not rebuilt; it reads the run's value with config.For(context).
Configure Child Harnesses
SubAgentRunConfig.Harnesses applies to direct child agents. It uses the same generated override types and patch rules as AgentRunConfig.Harnesses, but each named harness is resolved in the invoked child agent's registry:
var childRun = new SubAgentRunConfig
{
Target = SubAgentTarget.All
};
childRun.Harnesses
.For<SearchHarness>()
.Override(new SearchConfigOverrides
{
MaxResults = 5
});
await parentAgent.RunAsync(
"Research the request",
subAgentRunConfigs: [childRun]);To give descendants of that child an explicit default, use SubAgentRunDefaults.Harnesses:
var descendantDefaults = new SubAgentRunDefaults();
descendantDefaults.Harnesses
.For<SearchHarness>()
.Override(new SearchConfigOverrides
{
MaxResults = 3
});
var childRun = new SubAgentRunConfig
{
DescendantDefaults = descendantDefaults
};The same portable shape is available in serialized run configuration:
subAgentRunConfigs:
- target:
kind: all
harnesses:
- name: SearchHarness
config:
maxResults: 5Parent AgentRunConfig.Harnesses is never forwarded automatically. The child must register the named owner and has its own construction settings, dependencies, middleware, and runtime configuration binding.
Isolation And Ownership
- Each accepted input captures its own immutable effective snapshot.
- Concurrent runs cannot mutate one another’s harness settings.
- A handle from a different agent or harness owner is rejected.
- Run overrides do not replace constructor dependencies.
- Run overrides do not recreate shared middleware resources.
- Parent harness overrides do not propagate implicitly to a child; use
subAgentRunConfigsfor an explicit targeted child setting. SubAgentRunDefaults.Harnessesprovides explicit defaults for further descendants.- The internal agent and harness binding is runtime-only and is not serialized.
This API changes harness settings for an execution. It is not a live configuration update for an agent the runtime already built. To change a stored agent's settings, update its definition with runtime.Agents.UpdateAsync(...); the next run builds the new definition.