microsoft / microsoft/agent-framework
.NET: allow a custom JsonSerializerOptions (source-generated) for agent-hooks wire projection
Nobody has claimed this yet.
- 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) deserializesAIContentpolymorphically and must use the same options. - The
ResponsibleAI.AgentHooksSDK itself operates onJsonNodeand is unaffected.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.