Use Case
We need to intercept MCP tool invocations within nested agents (e.g., FinancialAgent called via handoff from TriageAgent) to implement Human-in-the-Loop (HITL) approval workflows.
Our application requires user confirmation before executing write operations (create transactions, update budgets, delete records). The workflow involves:
- User sends message to TriageAgent
- TriageAgent hands off to FinancialAgent (or other specialized agent)
- FinancialAgent invokes MCP tools (e.g.,
register_expense)
- Before tool execution, we need to suspend workflow and request user approval
- Resume workflow after approval with same context
Current Limitation
response.Messages only exposes top-level handoffs (e.g., handoff_to_1)
- MCP tool invocations within handoffed agents are hidden from the response
- No callback API available to intercept tool execution before it occurs
- Documentation references
CallbackMiddleware<AgentFunctionInvocationCallbackContext> but classes don't exist in preview
Evidence from our investigation:
// What we receive in response.Messages:
FunctionCallContent { Name: "handoff_to_1" } // ❌ Handoff, not tool name
// What we need to intercept:
FunctionCallContent { Name: "register_expense" } // ✅ Actual MCP tool
Package version tested: Microsoft.Agents.AI 1.0.0-preview.260212.1
Requested API
1. Function Invocation Callback Middleware
public class AgentFunctionInvocationCallbackContext
{
public AIFunction Function { get; set; }
public AIFunctionArguments Arguments { get; set; }
public bool Terminate { get; set; } // Suspend workflow before execution
}
public abstract class CallbackMiddleware<TContext>
{
public abstract Task OnProcessAsync(
TContext context,
Func<TContext, Task> next,
CancellationToken cancellationToken);
}
2. Expose Nested Tool Calls in Response
Either:
- Option A: Include nested tool invocations in
response.Messages (e.g., register_expense alongside handoff_to_1)
- Option B: Invoke callbacks BEFORE tool execution (even for nested tools within handoffs)
3. Checkpoint Resumption with Context
- Resume workflow from suspended state after approval
- Restore exact context at suspension point
- Execute approved tool with original arguments
Workaround Impact
Without this API:
- ❌ ALL write operations execute without user confirmation
- ❌ Violates GDPR/LGPD compliance (no explicit consent for data mutations)
- ❌ Cannot implement HITL workflows for 22 critical operations
- ❌ Users may create accidental transactions/deletions
Business Impact: Cannot deploy to production without HITL compliance.
Related Documentation
Proposed Timeline
This is a blocking issue for production deployment. We have prepared code for callback implementation and are ready to integrate as soon as the API is available.
Thank you for considering this feature request!
Use Case
We need to intercept MCP tool invocations within nested agents (e.g., FinancialAgent called via handoff from TriageAgent) to implement Human-in-the-Loop (HITL) approval workflows.
Our application requires user confirmation before executing write operations (create transactions, update budgets, delete records). The workflow involves:
register_expense)Current Limitation
response.Messagesonly exposes top-level handoffs (e.g.,handoff_to_1)CallbackMiddleware<AgentFunctionInvocationCallbackContext>but classes don't exist in previewEvidence from our investigation:
Package version tested:
Microsoft.Agents.AI 1.0.0-preview.260212.1Requested API
1. Function Invocation Callback Middleware
2. Expose Nested Tool Calls in Response
Either:
response.Messages(e.g.,register_expensealongsidehandoff_to_1)3. Checkpoint Resumption with Context
Workaround Impact
Without this API:
Business Impact: Cannot deploy to production without HITL compliance.
Related Documentation
.UseCallbacks()exists but requiresCallbackMiddleware<T>(not available)Proposed Timeline
This is a blocking issue for production deployment. We have prepared code for callback implementation and are ready to integrate as soon as the API is available.
Thank you for considering this feature request!