{
  "id": 14994889,
  "title": "My fix was one line. Code review found two holes in it.",
  "url": "https://urgent.news/2026/10/16/my-fix-was-one-line-code-review-found-two-holes-in-it",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-16T16:48:20.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ayoub_hammoudi/my-fix-was-one-line-code-review-found-two-holes-in-it-k0m"
  },
  "original_language": "en",
  "account": "I made a single-line fix to the Microsoft Agent Framework that the code review discovered had two issues. The bug only caused a problem when the framework called Gemini without streaming; using streaming could make the model name disappear. The framework tracks metrics based on the model name through OpenTelemetry, and when streaming, certain metrics lost that dimension. Each request still succeeded, but the per-model cost and latency view had a missing piece.\n\nThe streaming parser copied the model_version field into the update, so a chunk without it produced an update without a model. The aggregator kept the last non-empty value it saw, and a stream with no version ended with no model. The non-streaming parser handled this by falling back to the configured model when none was provided. However, the streaming path did not have a fallback, leading to two problems.\n\nFirst, I had previously questioned whether the client's default model was the appropriate fallback, and the automated reviewer confirmed it. The fallback used the client's default model, not the requested one. If a client was configured for gemini-2.5-flash but called with gemini-2.5-pro, the request would be labeled as Flash, and the metrics would reflect that. The fix now takes the requested model as an argument instead of the default.\n\nSecond, the maintainer found that applying the fallback chunk by chunk could overwrite the version the server had already reported. If an early chunk specified gemini-2.5-pro-002 and the final chunk had no version, the aggregator would replace the precise version with the requested alias gemini-2.5-pro. The fix needed to remember the server's version for the entire stream, not just each chunk.\n\nAfter three iterations and four tests, the final fix remembered the server's version throughout the stream and handled both fallback scenarios correctly. The review process involved multiple tests, including checking that the version from a chunk was kept, the fallback to the configured model, the fallback to the requested model, and replaying the maintainer's exact case with an observed server version surviving a later chunk that omitted it. The last test failed on the previous commit, highlighting the importance of the changes.\n\nI, Ayoub Hammoudi, a backend and AI platforms engineer in Paris, implemented this fix, which is available in the microsoft/agent-framework#9139 PR.",
  "summary": "The bug I fixed in Microsoft Agent Framework did not crash anything. That is what made it worth fixing. When the framework called Gemini without streaming, the response knew which model had answered. When it made the same call with streaming, the model name could disappear on the way. The framework records its metrics through OpenTelemetry, and the model name is one of the dimensions those…",
  "key_points": [
    "Single-line fix discovered two issues in Microsoft Agent Framework",
    "Streaming parser lost model name, causing metric and latency problems",
    "Fix remembered server's version throughout stream, resolved fallback issues"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}