diff --git a/ResearcherAgent.cs b/ResearcherAgent.cs index eda3a41..bc86bf7 100644 --- a/ResearcherAgent.cs +++ b/ResearcherAgent.cs @@ -50,6 +50,20 @@ public ResearcherAgent(IChatClient llm, ChatOptions chatOptions, AIFunction tavi }, }) .AsBuilder() + // Function-invocation middleware: fires around every tool call the agent + // makes. We log each time the model invokes the Tavily search tool. + .Use(async (agent, context, next, cancellationToken) => + { + if (context.Function.Name == tavilyTool.Name) + { + _logger.LogInformation( + "Researcher invoking Tavily tool '{Tool}' with arguments {Arguments}", + context.Function.Name, + context.Arguments); + } + + return await next(context, cancellationToken); + }) .UseOpenTelemetry(sourceName: "BlogWriter.Agents") .Build();