You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extracted the Anthropic provider's repeated JSON schema-to-map conversion into an unexported helper. This keeps tool schema setup and structured output schema setup routed through one internal conversion path, closer to the sampled .NET Anthropic JSON context pattern where supported JSON payload shapes are centralized.
.NET Reference
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicClientJsonContext.cs - centralizes Anthropic JSON serializer support for JSON elements, strings, and dictionary payloads.
Public API and Behavior
No public Go API changed. No intentional behavior change was made.
Tests
gofmt -w provider/anthropicprovider/agent.go
go test ./provider/anthropicprovider
Notes
Rejected candidates from the random .NET sample:
dotnet/src/Microsoft.Agents.AI.Abstractions/AdditionalPropertiesExtensions.cs - rejected because the corresponding Go additional-properties maps are public struct fields, and adding typed helpers would change the public API surface.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/InputMessageContent.cs - rejected because Go relies on the OpenAI SDK response input union types, and reshaping that path would be broader than a tiny internal portability cleanup.
dotnet/src/Microsoft.Agents.AI/Harness/FileStore/FileSearchResult.cs - rejected because no direct Go file-store/file-search result counterpart was identified for a safe structural cleanup.
Open [dotnet-code] PR search found existing PRs in superstep tracing, compaction provider reduction, and message merger folding, but no open Anthropic-specific overlap.
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-code-anthropic-schema-helper-20260724224621-4fc322987229382e.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (92 of 92 lines)
From 6cfc19cdd7a787ad37a06c95c5132abbd5c1b2b1 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 24 Jul 2026 22:46:21 +0000
Subject: [PATCH] Extract Anthropic schema map helper
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
provider/anthropicprovider/agent.go | 53 ++++++++++++++---------------
1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/provider/anthropicprovider/agent.go b/provider/anthropicprovider/agent.go
index be7b5ab26..ca0b66283 100644
--- a/provider/anthropicprovider/agent.go+++ b/provider/anthropicprovider/agent.go@@ -310,22 +310,9 @@ func (a *client) buildMessageParams(messages []*message.Message, opts []agent.Op
var properties any
var required []string
- // Extract schema details - first convert to map[string]any if needed- schema := ft.Schema()- var schemaMap map[string]any-- switch s := schema.(type) {- case map[string]any:- schemaMap = s- default:- // For *jsonschema.Schema or other types, marshal to JSON then unmarshal to map- if schema != nil {- jsonBytes, err := json.Marshal(schema)- if err == nil {- _ = json.Unmarshal(jsonBytes, &schemaMap)- }- }- }+ // Preserve existing lenient tool schema handling: unusable schemas+ // simply leave properties and required empty.+ schemaMap, _ := schemaMapFromAny(ft.Schema())
if schemaMap != nil {
if props, ok := schemaMap["properties"]; ok {
@@ -386,18 +373,9 @@ func (a *client) buildMessageParams(messages []*message.Message, opts []agent.Op
if frmt, ok := agent.GetOption(opts, agent.WithResponseFormat); ok {
if frmt.Kind == "json" {
if schema := frmt.Schema; schema != nil {
- var schemaMap map[string]any- switch s := schema.(type) {- case map[string]any:- schemaMap = s- default:- jsonBytes, err := json.Marshal(s)- if err != nil {- return anthropic.MessageNewParams{}, fmt.E
... (truncated)
Summary
Extracted the Anthropic provider's repeated JSON schema-to-map conversion into an unexported helper. This keeps tool schema setup and structured output schema setup routed through one internal conversion path, closer to the sampled .NET Anthropic JSON context pattern where supported JSON payload shapes are centralized.
.NET Reference
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicClientJsonContext.cs- centralizes Anthropic JSON serializer support for JSON elements, strings, and dictionary payloads.Public API and Behavior
No public Go API changed. No intentional behavior change was made.
Tests
gofmt -w provider/anthropicprovider/agent.gogo test ./provider/anthropicproviderNotes
Rejected candidates from the random .NET sample:
dotnet/src/Microsoft.Agents.AI.Abstractions/AdditionalPropertiesExtensions.cs- rejected because the corresponding Go additional-properties maps are public struct fields, and adding typed helpers would change the public API surface.dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/Models/InputMessageContent.cs- rejected because Go relies on the OpenAI SDK response input union types, and reshaping that path would be broader than a tiny internal portability cleanup.dotnet/src/Microsoft.Agents.AI/Harness/FileStore/FileSearchResult.cs- rejected because no direct Go file-store/file-search result counterpart was identified for a safe structural cleanup.Open
[dotnet-code]PR search found existing PRs in superstep tracing, compaction provider reduction, and message merger folding, but no open Anthropic-specific overlap.Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
dotnet-code-anthropic-schema-helper-20260724224621-4fc322987229382e.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (92 of 92 lines)