Inspiration

Coding agents such as Google Antigravity (agy), Claude Code, and GitHub Copilot Workspace are remarkable at synthesizing multi-file software projects. However, almost every time we use them we encounters the exact same frustrating failure modes.

  1. Premature Completion Bias: The agent implements 80% of a feature, leaves hollow mock stubs or broken imports, and announces: "I have completed your task!"
    1. The "Human Proctor" Problem: The human developer is forced to manually inspect the terminal, spot broken unit tests, copy-paste compiler logs, and repeatedly re-prompt the agent to fix its mistakes.
    2. Self-Grading Bias: When an LLM is asked to review its own output, it suffers from severe confirmation bias. An independent, impartial udge is structurally required to hold the agent to professional software engineering standards.
      We asked ourselves: What if an AI coding agent literally could not exit until its code was deterministically proven to compile, pass 100% of automated tests, and satisfy an independent machine learning decision model?
      That question gave birth to Median—an autonomous, two-tier quality gate and verification engine that transforms AI coding from a one-shot guess into a self-correcting closed loop.

What it does

Median act as a strict senior developer sitting right beside the AI agent, making sure no broken code slips through it , :

  1. Finding Bugs: As soon as the agent writes code, Median runs a quick compiler check. If types or imports break, it flags them immediately so errors don't pass through it and break the code.
    1. Tier 0 (The Test Gate): When the agent tries to say "I'm done!", Median intercepts it and runs the actual build and test suites. If anything fails, it blocks completion and hands the error logs back to the agent: "Not yet—fix these tests first."
    2. Tier 1 (The ML Decision Gate): Passing tests is great, but did the agent actually build what you asked for, or did it just write dummy mocks? Median sends the code diff and your original prompt to a local model (here we have used clodflare clef-flash model) . Clef evaluates intent fulfillment and calculates a confidence score (noul). If confidence hits 90% or higher or noul ≥ 0.90 , the agent is cleared to finish. If not, it points outwhat was missed and sends the agent back to finish the job .

How we built it

-For integration we have built Median as a plugin for different agents utilizing plugin.json and hooks.json. -Intercepts Stop and PostInvocation events, parses conversation trajectories from transcript.jsonl, and dynamically isolates the active project directory. ** Core verification engine ** -Developed in pure typescript on Node.js

  • Deterministic test parsing for vitest, jest, and tsc with repeated error signature tracking

[Agent Emits Code Edits] │ v [Early PostInvocation Gate] ──> Compile errors? ──> YES ──> Injects error & forces instant fix │ (Clean) v [Agent Attempts Completion (model_stop)] │ v ┌───────────────────────────────────────┐ │ Tier 0: Deterministic Gate │ │ • npm run build / tsc --noEmit │ │ • npm test (vitest / jest) │ └───────────────────┬───────────────────┘ │ All checks passed? ├── NO ──> Return { decision: "continue", reason: "Fix tests..." } ──> Agent Self-Corrects └── YES ──> Ambiguous Goal Fulfillment? ├── YES ──> [Tier 1: Cloudflare Clef-Flash Decision Model] │ ├── noul ≥ 0.90 ──> Return { decision: "allow" } ──> Done! │ └── noul < 0.90 ─> Return { decision: "continue", reason: "..." } └── NO ──> Return { decision: "allow" } ──> Done!

Challenges we ran into

1- So , when we initially prototypes Median , we designed it as an external cli wrapper that launched agent as a child process in IDE , but we soon hit a wall as restarting agent externally wiped out all the conversation context, intermediate scratchpads and made it impossible to use in IDEs, so we changed it to a completely in-process lifecycle plugin where the agent is the host and median act as a nativce gatekeeper.
2- On our early stage of development we were relying on Laya that was based on ModernBert, but it was only limited to ~512 tokens which was very less in real world as a simple git diffs between multiple files can consume thousand of tokens so we switched to new cloudflare-clef-flash model which provider around 65,536 tokens context window. 3-We wanted median to be 100% accessible to individual developers who were working on a laptop.Running a 9B model on a consumer GPU (e.g. NVIDIA RTX 3050 6GB) required fine-tuning batch sizes (ubatch-size 512), context reservations (ctx-size 2048), and 4-bit Medium quantization to keep the footprint under 5.2 GB of VRAM.

Accomplishments that we're proud of

1- TRUE AUTONOMOUS CORRECTION i.e. the agets running with median genuinely self-correct . 2- Massive Token savings

What we learned

We learned many things like how AI agent runtimes and plugin systems actually tick. We learned how lifecycle hooks (PostInvocation and Stop) intercept agent actions, how agents process error feedback, and how to inject corrections directly into their workflow. We realized that making agents reliable isn’t about prompting harder but it is about building surgical plugin hooks that keep the agent accountable at every step.

What's next for MEDIAN

1- Multi-Dimensional Semantic Scoring: Moving from a single binary score to automated requirement extraction (R₁, R₂, …) and typed checks for stub detection, regression risk, and test adequacy. 2- Evidence Graphs & State Fitting: Introducing context-budget fitting (adapting fast-jev techniques) to feed rich compiler logs and test traces without overflowing context windows. 3-Configurable Enterprise Policies: Adding strict fail-closed modes so offline verifiers never accidentally allow unverified code into production. 4-Polyglot Ecosystem: Expanding pluggable check runners to Python (pytest/mypy), Rust (cargo check), and Go, alongside standalone VS Code and MCP integrations.

Built With

Share this project:

Updates

Submission history