microsoft / microsoft/agent-host-protocol
.NET client: support trimming and Native AOT
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 344
- Forks
- 122
- Avg merge
- 14h 12m
- Merged PRs (30d)
- 22
Description
Summary
Make the first-party .NET client introduced in #206 trimming-safe and compatible with Native AOT.
Current limitation
The current JSON path relies on runtime reflection:
SystemTextJsonAhpSerializeruses reflection-basedSystem.Text.Jsonserialization.UnionConverter<T>resolves and deserializes runtime variant types.WireEnumConverter<T>reflects over enum fields andWireValueAttributemetadata.- Public serializer APIs are marked with
RequiresUnreferencedCodeandRequiresDynamicCode. - The packages intentionally do not claim
IsTrimmableorIsAotCompatible.
Proposed work
- Generate or maintain a
JsonSerializerContextcovering the complete generated protocol surface and hand-written envelope types. - Update
SystemTextJsonAhpSerializerto use generatedJsonTypeInfometadata. - Replace reflection-based union and wire-enum lookup with generated/static metadata.
- Preserve unknown discriminants and wire values exactly as required by the protocol.
- Remove
RequiresUnreferencedCode/RequiresDynamicCodefrom supported public paths. - Set appropriate package compatibility properties (
IsTrimmable/IsAotCompatible) once validated. - Add CI coverage that publishes and runs a representative client with trimming and Native AOT enabled.
Acceptance criteria
dotnet publishsucceeds for a representative client withPublishAot=trueand no AHP-originated trim/AOT warnings.- Existing reducer and round-trip fixtures remain green.
- Unknown union discriminants continue to round-trip verbatim.
- Both
netstandard2.0andnet8.0package targets continue to build.
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.
Research direction
Start with SystemTextJsonAhpSerializer, UnionConverter, and WireEnumConverter; trace the generated protocol and hand-written envelope types they cover. Run the existing reducer and round-trip fixtures, then publish a representative client with PublishAot=true for the netstandard2.0 and net8.0 targets. Done means no AHP-originated trim/AOT warnings, unknown values round-trip, and both targets build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, build-system, ci-cd
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100