Qwen generates code. Sometimes that code is wrong in predictable ways — unclosed brackets, hallucinated imports, truncated output, missing shebangs, duplicate definitions. The kind of errors that a human would catch immediately but that break automated execution silently.

I built a code fixer that sits in the file-write pipeline. Every piece of code the worker produces passes through it before touching the filesystem. It’s not a linter — it’s a repair layer.

The prototype started with Python (the most common output language) and scored 98 out of 99 across 10 language test cases with zero external dependencies. That was encouraging enough to build it out properly.

Version 2 added parso-based Python parsing, json-repair for malformed JSON, and handlers for JavaScript, TypeScript, Markdown, and YAML. Version 2.5 expanded to 7 auto-fixers (bracket mismatch repair, hallucinated import removal, missing stdlib imports, shell shebang repair, block closers, HTML attribute quote repair, entity encoding) and 6 detectors (truncation, duplicate definitions, cross-language truncation, unsafe code patterns).

The hallucinated import fixer is my favourite. Qwen regularly generates from typing import ContextManager or from collections import DefaultDict — imports that look right but don’t exist in Python’s standard library. The fixer maintains an allowlist of real stdlib symbols and silently removes the fakes.

The code fixer is gated to known file types only, and it never changes semantics — it only repairs syntax. If it can’t fix something confidently, it leaves it alone. The principle is the same as everywhere else in the pipeline: fail safe, not clever.