Skip to content
9 changes: 9 additions & 0 deletions dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ private static ChatClientAgent BuildInnerAgent(IChatClient chatClient, HarnessAg
// Build ChatClient stack
ChatClientBuilder chatClientBuilder = chatClient.AsBuilder();

// Registered first so it sits as the outermost decorator, above the approval-not-required bypassing
// and function invocation middleware, so it can bind inbound approval responses to the requests the
// framework surfaced. The harness uses UseProvidedChatClientAsIs, so this is added manually here rather
// than via the default ChatClientAgent pipeline.
if (options?.DisableApprovalResponseBinding is not true)
{
chatClientBuilder.UseApprovalResponseBinding();
}

if (options?.DisableApprovalNotRequiredFunctionBypassing is not true)
{
chatClientBuilder.UseApprovalNotRequiredFunctionBypassing();
Expand Down
13 changes: 13 additions & 0 deletions dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgentOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ public sealed class HarnessAgentOptions
/// </remarks>
public bool DisableApprovalNotRequiredFunctionBypassing { get; set; }

/// <summary>
/// Gets or sets a value indicating whether binding inbound tool-approval responses to the
/// model-originated approval requests that the framework surfaced is disabled.
/// </summary>
/// <remarks>
/// When <see langword="false"/> (the default), the underlying chat client pipeline includes the decorator
/// added by <see cref="ChatClientBuilderExtensions.UseApprovalResponseBinding"/> as the outermost decorator
/// above the function invocation middleware. It records each surfaced approval request and, on the next
/// request, binds every approval response to its recorded request so an approved call matches exactly what
/// was surfaced for approval.
/// </remarks>
public bool DisableApprovalResponseBinding { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="FileMemoryProvider"/> is disabled.
/// </summary>
Expand Down
Loading
Loading