mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
2ad0caf069
* fix: use HasSchema check in DetermineElementType to prevent empty records When parsing JSON arrays containing objects without a predefined schema, `DetermineElementType()` was creating a `VariableType` with an empty (non-null) schema via `targetType.Schema?.Select(...) ?? []`. This caused `ParseRecord` to take the schema-based parsing path, iterating over zero schema fields and silently discarding all JSON properties. The fix checks `targetType.HasSchema` and falls back to `VariableType.RecordType` (which has `Schema = null`) when no schema is defined, ensuring `ParseRecord` takes the dynamic `ParseValues()` path that preserves all JSON properties. Closes #4195 * test: add regression tests for schema-less JSON array-of-objects parsing (#4195) Add two regression tests to JsonDocumentExtensionsTests: 1. ParseRecord_ObjectWithArrayOfObjects_NoSchema_PreservesNestedProperties - Parses a JSON object containing an array of objects using VariableType.RecordType (no schema) and verifies that nested object properties (name, role) are preserved in each element. - This is the exact scenario from issue #4195 where objects in arrays were being returned as empty dictionaries. 2. ParseList_ArrayOfObjects_NoSchema_PreservesProperties - Parses a JSON array of objects directly via ParseList with VariableType.ListType (no schema) and verifies all properties are preserved. Both tests follow the existing Arrange/Act/Assert pattern and would have failed before the DetermineElementType() fix (empty dictionaries instead of populated ones).
2ad0caf069
ยท
2026-02-25 01:02:43 +00:00
History
Get Started with Microsoft Agent Framework for C# Developers
Samples
- Getting Started with Agents: basic agent creation and tool usage
- Agent Provider Samples: samples showing different agent providers
- Workflow Samples: advanced multi-agent patterns and workflow orchestration
Quickstart
Basic Agent - .NET
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using OpenAI.Responses;
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!;
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME")!;
var agent = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
.GetResponsesClient(deploymentName)
.AsAIAgent(name: "HaikuBot", instructions: "You are an upbeat assistant that writes beautifully.");
Console.WriteLine(await agent.RunAsync("Write a haiku about Microsoft Agent Framework."));
Examples & Samples
- Getting Started with Agents: basic agent creation and tool usage
- Agent Provider Samples: samples showing different agent providers
- Workflow Samples: advanced multi-agent patterns and workflow orchestration