microsoft / microsoft/agent-framework
.NET: [Feature]: Automatically fix malformed JSON responses from LLMs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
Description
While working with LLMs for tool calling and structured outputs, the models occasionally return malformed or slightly corrupted JSON responses. Common issues include:
- Markdown Fences: Wrapping the JSON block inside markdown formatting (e.g., ```json ... ```).
- Trailing Commas: Leaving trailing commas at the end of objects or arrays (which standard System.Text.Json strictly rejects with a JsonException).
- Truncated Outputs: Cut-off responses due to token limits, resulting in missing closing brackets (}, ]).
- Stringified Fields: Embedding raw objects inside stringified attributes (e.g., "arguments": "{\"key\": \"value\"}" instead of "arguments": {"key": "value"}).
Implementing this at the gateway of our parser layer will drastically improve system resilience, cut down on redundant error handling, and make our integration with LLMs much more production-ready.
Code Sample
Language/SDK
.NET
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 by locating the .NET parser layer that uses System.Text.Json and review how malformed LLM responses enter it. Define and test the intended handling for markdown fences, trailing commas, truncated brackets, and stringified fields; done means these listed response forms are repaired or handled consistently without the current JsonException failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- ai, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100