Inspiration

Every software engineering team has experienced the Friday 5:00 PM security advisory: a critical vulnerability alert (SQL Injection, Path Traversal, SSRF, or Deserialization) hits the incident queue. Engineers scramble through unfamiliar legacy codebases, search GitHub issues and CVE databases for known remediations, write hasty patches, and pray the syntax doesn't break production builds.

We asked ourselves: What if an autonomous agent could orchestrate this entire lifecycle in seconds — not just generating speculative code, but verifying AST syntax, validating unified diff boundaries, and leveraging live threat intelligence before handing a verified .patch file to the developer?

With the launch of Nebius Token Factory offering ultra-high throughput inference for NVIDIA Nemotron foundation models, and the real-time search capabilities of Tavily, building this autonomous reliability engineer became a reality.

What PatchForge-Nemotron Does

PatchForge acts as an autonomous tier-1 and tier-2 AppSec reliability engineer:

  • Interactive Intake & Presets: Ingests vulnerability reports, stack traces, and vulnerable source files. Comes pre-loaded with 5 representative enterprise vulnerability scenarios: CWE-89 SQL Injection, CWE-22 Path Traversal, Race Condition in Atomic Balance Deduction, CWE-918 SSRF, CWE-502 Insecure Deserialization.
  • Hierarchical Dual-Tier Nemotron Architecture on Nebius Token Factory: Tier 1 (Fast Triage & Syntax Guard, Nemotron Nano) ingests raw stack traces and code, extracts the exact suspect lines, classifies severity (LOW to CRITICAL), and guards initial AST structure at sub-second speeds. Tier 2 (Deep RCA & Surgical Synthesis, Nemotron 3 Ultra) performs deep multi-hop reasoning over code execution flows, designs remediation strategies that preserve API compatibility, and synthesizes unified diffs.
  • Live Upstream Intelligence via Tavily Search API: Queries authoritative security advisory feeds, NIST NVD patterns, and vendor remediations for the identified vulnerability pattern, grounding Nemotron's reasoning in verified industry best practices.
  • Hermetic Pre-Commit Verifier Engine (PatchVerifier): Validates Python AST compilation to guarantee zero syntax regressions, enforces generic bracket matching, measures surgical diff statistics, and guarantees valid POSIX patch format consumable directly by git apply.
  • Real-Time Streaming UX & SSE: Delivers step-by-step reasoning progress across 10 discrete workflow phases via Server-Sent Events, complete with an interactive dashboard, diff syntax highlighting, and 1-click .patch download.

How We Built It

  • Agent Core & Orchestration: Python 3.11+ and FastAPI, modular DAG pipeline (Triage -> Search -> RCA -> Synthesize -> Verify -> Package).
  • Nebius Token Factory Integration (app/agent/nebius_client.py): OpenAI-compatible API at api.tokenfactory.nebius.com/v1, clean abstraction bindings for the Nemotron Nano (triage) and Nemotron 3 Ultra (reasoning) models, with exponential backoff and structured output parsing.
  • Tavily Search API Integration (app/agent/tavily_client.py): Contextual security search filtering on CVE identifiers, remediation snippets, and security advisories.
  • AST & Diff Verification Engine (app/core/verifier.py): Custom hermetic analyzer verifying code integrity before patch release.
  • Frontend Dashboard: Tailwind CSS and FontAwesome, interactive preset chips, live terminal stream logs, visual diff inspectors.
  • Deployment: Multi-stage Dockerfile and docker-compose.yml supporting 1-click deployment on Hugging Face Spaces, Render, or Oracle Cloud Always-Free.

Bonus Category: Best Use of Tavily

PatchForge-Nemotron embeds the Tavily Search API directly into the core decision DAG. When a vulnerability is triaged, Tavily executes targeted security advisory queries; the results are injected into Nemotron 3 Ultra's prompt context. This eliminates model hallucination, ensures compliance with current secure coding standards, and lets PatchForge discover upstream patches for third-party library flaws without manual operator research.

Dual-Mode Architecture: Zero-Friction Judge Evaluation

  • Live Mode: When NEBIUS_API_KEY and TAVILY_API_KEY are provided, the agent connects live to Nebius Token Factory and Tavily.
  • Hermetic Simulation Mode: When keys are omitted, PatchForge switches to its built-in deterministic simulator. Judges can explore all 5 vulnerability presets, watch SSE streaming events, inspect unified diffs, and download .patch files with zero API keys required.

Challenges We Ran Into

  1. Ensuring Surgical Patches: Early prompt iterations caused LLMs to rewrite entire files rather than producing minimal, reviewable diffs. We constrained Nemotron 3 Ultra with strict unified diff formatting rules and built PatchVerifier to reject full-file rewrites.
  2. Balancing Latency and Reasoning: Running heavy 500B+ models for trivial log parsing slowed the feedback loop. Offloading triage to Nemotron Nano cut end-to-end latency by 65%.
  3. Hermetic Reproducibility: Ensuring test suite execution across varied host environments required strict pythonpath isolation and mocked network layers.

Accomplishments We're Proud Of

  • 19/19 Unit & Integration Tests Passing: pytest suite covering API endpoints, client abstractions, AST verification, and full pipeline scenarios.
  • Clean POSIX Unified Diffs: Patches generated by PatchForge can be piped directly into git apply --check without manual editing.
  • Zero-Credential Readiness: Judges can evaluate the project immediately without creating accounts or setting up secrets.

What We Learned

  • The NVIDIA Nemotron family provides exceptional instruction-following capability for structured tasks like AST verification and diff generation.
  • Pairing real-time web search (Tavily) with specialized reasoning models creates a compound agent far superior to static code generators.

What's Next for PatchForge-Nemotron

  • GitHub Action & GitLab Bot: monitor CI failures and security scan alerts, open pull requests with pre-verified fixes.
  • Polyglot AST Expansion: extend AST verification beyond Python to TypeScript, Go, and Rust.
  • Dynamic Sandbox Execution: execute synthesized patches against isolated Docker microVMs to run unit test regressions automatically.

Built With

  • docker
  • fastapi
  • nebius-token-factory
  • nvidia-nemotron
  • python
  • tailwind-css
  • tavily
Share this project:

Updates

Submission history