Skip to content

.NET: [Feature]: .NET Improve ChatClientAgentSession constructor #7109

Description

@Kumima

Description

internal ChatClientAgentSession(string? conversationId, AgentSessionStateBag? stateBag) : base(stateBag ?? new())

I have this setting for my solution. It's a more strict setting for deserialization.

<RuntimeHostConfigurationOption
    Include="System.Text.Json.Serialization.RespectRequiredConstructorParametersDefault"
    Value="true" />

The default option uses JsonIgnoreCondition.WhenWritingNull, and when the json is deserialized, the required parameters will not be provided.

There can be multiple solutions:

  • Do not use that settings, but I want to keep it.
  • internal ChatClientAgentSession(string? conversationId, AgentSessionStateBag? stateBag) => internal ChatClientAgentSession(string? conversationId = null, AgentSessionStateBag? stateBag = null). Provide default values for constructor.
  • Makes the constructor public, so a custom serialization options can be provided. We seems to need a public constructor for custom serialization. Then I can override that JsonIgnoreCondition.WhenWritingNull.

Code Sample

Language/SDK

.NET

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agent

Fields

No fields configured for Feature.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions