Skip to content

Commit bedc2dc

Browse files
committed
Added Google Raw HTTP Details Support (still not released)
1 parent 8dfd828 commit bedc2dc

9 files changed

Lines changed: 48 additions & 9 deletions

File tree

AgentFrameworkToolkit.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MCP/@EntryIndexedValue">MCP</s:String>
44
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=XAI/@EntryIndexedValue">XAI</s:String>
55
<s:Boolean x:Key="/Default/UserDictionary/Words/=Cerebras/@EntryIndexedValue">True</s:Boolean>
6+
<s:Boolean x:Key="/Default/UserDictionary/Words/=googleapis/@EntryIndexedValue">True</s:Boolean>
67
<s:Boolean x:Key="/Default/UserDictionary/Words/=MEAI/@EntryIndexedValue">True</s:Boolean>
78
<s:Boolean x:Key="/Default/UserDictionary/Words/=xhigh/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog - Agent Framework Toolkit
22

3+
## Unreleased
4+
- Google: Added support for inspecting HttpRawCall Details
5+
6+
---
7+
38
## Version 1.6.1 (14th of May 2026)
49
- Updated Agent Framework from 1.5.0 to 1.6.1 [NOTE: Due to dependency incompatibility, there is no package in this release that targets Google; it will return once Google updates their dependencies]
510
- Updated all NuGet packages to the latest

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<PackageVersion Include="Microsoft.Extensions.AI.AzureAIInference" Version="10.0.0-preview.1.25559.3" />
1818
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.8" />
1919
<!-- Third-party AI SDKs -->
20-
<PackageVersion Include="Google.GenAI" Version="1.6.1" />
20+
<PackageVersion Include="Google.GenAI" Version="1.6.2" />
2121
<PackageVersion Include="Mistral.SDK" Version="2.3.1" />
2222
<PackageVersion Include="ModelContextProtocol" Version="1.3.0" />
23-
<PackageVersion Include="AWSSDK.BedrockRuntime" Version="4.0.17.7" />
24-
<PackageVersion Include="AWSSDK.Extensions.Bedrock.MEAI" Version="4.0.8.1" />
23+
<PackageVersion Include="AWSSDK.BedrockRuntime" Version="4.0.17.8" />
24+
<PackageVersion Include="AWSSDK.Extensions.Bedrock.MEAI" Version="4.0.8.2" />
2525
<!-- Code analysis -->
2626
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.4" />
2727
<!-- Testing -->

development/Sandbox/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
Console.Clear();
77

88
Console.OutputEncoding = Encoding.UTF8;
9-
await Sandbox.Providers.Anthropic.RunAsync();
9+
//await Sandbox.Providers.Anthropic.RunAsync();
1010
//await Sandbox.Providers.AmazonBedrock.RunAsync();
1111
//await Sandbox.Providers.OpenAI.RunAsync();
1212
//await Sandbox.Providers.GitHub.RunAsync();
1313
//await AzureOpenAI.RunAsync();
1414
//await Sandbox.Providers.Mistral.RunAsync();
15-
//await Sandbox.Providers.Google.RunAsync();
15+
await Sandbox.Providers.Google.RunAsync();
1616
//await Sandbox.Providers.XAI.RunAsync();
1717
//await Sandbox.Providers.OpenRouter.RunAsync();
1818
//await Sandbox.Providers.Cerebras.RunAsync();

development/Sandbox/Providers/Google.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ public static async Task RunAsync()
2020
GoogleAgentFactory agentFactory = new GoogleAgentFactory(new GoogleConnection
2121
{
2222
ApiKey = secrets.GoogleGeminiApiKey,
23+
2324
});
2425

2526
AIAgent agent = agentFactory.CreateAgent(new GoogleAgentOptions
2627
{
27-
Model = "gemini-3-pro-preview"
28+
Model = "gemini-3.1-pro-preview",
29+
RawHttpCallDetails = details =>
30+
{
31+
Console.WriteLine(details.RequestUrl);
32+
Console.WriteLine(details.RequestData);
33+
Console.WriteLine(details.ResponseData);
34+
}
2835
});
29-
await agent.RunAsync<string>("");
36+
await agent.RunAsync<string>("Hello");
3037

3138

3239
AgentResponse response = await agent.RunAsync("Why is the Sky Blue");

development/Tests/TestBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,12 @@ Task<GoogleAgentOptions> GetGoogleAgentOptions(string model)
580580

581581
return await next(context, token);
582582
},
583+
RawHttpCallDetails = details =>
584+
{
585+
Assert.True(details.RequestUrl.Contains("googleapis.com", StringComparison.InvariantCultureIgnoreCase));
586+
Assert.True(details.RequestData.Contains("parts", StringComparison.InvariantCultureIgnoreCase));
587+
Assert.True(details.ResponseData.Contains("parts", StringComparison.InvariantCultureIgnoreCase));
588+
},
583589
OpenTelemetryMiddleware = new OpenTelemetryMiddleware(sourceName, agent => agent.EnableSensitiveData = true),
584590
LoggingMiddleware = new LoggingMiddleware(testLogger)
585591
});

src/AgentFrameworkToolkit.Google/GoogleAgentFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public GoogleAgent CreateAgent(string model, string? instructions = null, string
6363
/// <returns>The Agent</returns>
6464
public GoogleAgent CreateAgent(GoogleAgentOptions options)
6565
{
66-
IChatClient client = Connection.GetClient().AsIChatClient(options.Model);
66+
IChatClient client = Connection.GetClient(rawHttpCallDetails: options.RawHttpCallDetails).AsIChatClient(options.Model);
6767

6868
AIAgent innerAgent = new ChatClientAgent(client, CreateChatClientAgentOptions(options), options.LoggerFactory, options.Services);
6969

src/AgentFrameworkToolkit.Google/GoogleAgentOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,9 @@ public class GoogleAgentOptions
113113
/// Gets or sets the list of <see cref="AIContextProvider"/> instances to use for providing additional context for each agent run.
114114
/// </summary>
115115
public IEnumerable<AIContextProvider>? AIContextProviders { get; set; }
116+
117+
/// <summary>
118+
/// An Action, if set, will attach an HTTP Message Handler so you can see the raw HTTP Calls that are sent to the LLM
119+
/// </summary>
120+
public Action<RawCallDetails>? RawHttpCallDetails { get; set; }
116121
}

src/AgentFrameworkToolkit.Google/GoogleConnection.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ public GoogleConnection(string project, string location)
7575

7676
/// <summary>
7777
/// Get a Raw Client
78+
/// <param name="rawHttpCallDetails">An Action, if set, will attach an HTTP Message Handler so you can see the raw HTTP Calls that are sent to the LLM</param>
7879
/// </summary>
7980
/// <returns>The Raw Client</returns>
80-
public Client GetClient()
81+
public Client GetClient(Action<RawCallDetails>? rawHttpCallDetails = null)
8182
{
8283
HttpOptions? httpOptions = HttpOptions;
8384
if (NetworkTimeout.HasValue)
@@ -95,10 +96,24 @@ public Client GetClient()
9596
}
9697
}
9798

99+
100+
ClientOptions? clientOptions = null;
101+
// ReSharper disable once InvertIf
102+
if (rawHttpCallDetails != null)
103+
{
104+
HttpClient inspectingHttpClient = new(new RawCallDetailsHttpHandler(rawHttpCallDetails));
105+
106+
clientOptions = new ClientOptions
107+
{
108+
HttpClientFactory = () => inspectingHttpClient
109+
};
110+
}
111+
98112
Client client = new(
99113
vertexAI: VertexAI,
100114
apiKey: ApiKey,
101115
credential: Credential,
116+
clientOptions: clientOptions,
102117
project: Project,
103118
location: Location,
104119
httpOptions: httpOptions);

0 commit comments

Comments
 (0)