microsoft / microsoft/agent-framework

.NET: allow a custom JsonSerializerOptions (source-generated) for agent-hooks wire projection

Open
#7,718 0 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

.NET
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

Feature request

Follow-up from review of #7564 (https://github.com/microsoft/agent-framework/pull/7564#discussion_r3803635610).

The agent-hooks enforcement package projects framework values (messages, rich content, tool arguments and results) into AGENT-HOOKS-0.1 wire JSON using reflection-based System.Text.Json via AIJsonUtilities.DefaultOptions (see Wire.JsonOptions in dotnet/src/Microsoft.Agents.AI.AgentHooks/Wire.cs). Because tool arguments/results are arbitrary user types, the project currently sets IsAotCompatible=false.

Proposal: allow a developer to supply a custom JsonSerializerOptions — built with source-generated JSON serialization — for the wire projection (e.g. an AgentHooksOptions.JsonSerializerOptions property defaulting to AIJsonUtilities.DefaultOptions). That gives source-gen/AOT-oriented applications a path to full trimming/AOT compatibility for this package and mirrors how the framework itself threads serializer options through its own surfaces.

Considerations:

  • The projection must stay faithful and fail-closed: a value the supplied options cannot serialize should keep the current repr-fallback (or fail closed at the guarded seams), never crash with a trail gap.
  • The write-back direction (Wire.WireToContents) deserializes AIContent polymorphically and must use the same options.
  • The ResponsibleAI.AgentHooks SDK itself operates on JsonNode and is unaffected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.