Inspiration

A job seeker reads dozens of posts a day. Some hide that a role has no guaranteed pay: it is commission-only, or unpaid. For context, people in the US reported losing $501 million to job and employment agency scams in 2024, up from $90 million in 2020 (FTC). That figure covers job scams of every kind (fake recruiters, fake checks, upfront fees), and hidden pay is only one warning sign among them, the one our ready-made check looks for. Signs like these are in the text, but nobody reads every post, email and review with a lawyer's eye. And a job search, an inbox or a pile of reviews is exactly the text you don't want to send to a server just to be warned about it.

On-device models are free, private and work offline. But they are small and fragile about prompting. Most people will never write a good prompt for Gemini Nano, and a prompt that works on one device's model often breaks on another. Big cloud models are the opposite: smart, but every call costs money and sends your text away.

So we asked: what if the cloud never saw your data at all? It would do only the one thing small models can't do for themselves, which is write and debug their own instructions.

Who it's for

People who read things that might be traps, and want a second pair of eyes that costs nothing and tells no one: job seekers sorting real roles from commission-only and pay-to-work posts, anyone whose inbox gets "pay now or lose access" emails, shoppers wading through reviews. Each of them has a different trap, so Cantrip lets them describe their own in one sentence instead of waiting for someone to build a detector for it.

What it does

You type a rule in plain English, like "Warn me when a job post is really commission-only."

  1. Gemini in the cloud designs a small program for the on-device model. The program has labels, a system prompt, examples and a dozen test cases.
  2. Cantrip runs every test on your device's model, live, and shows each pass and fail as it happens.
  3. Gemini reads the failures, works out why the small model got them wrong, and rewrites the program. It always keeps the best version so far.
  4. A third of the tests are held back from the repair loop, so the final "unseen tests" score is honest.
  5. From then on, the program runs on Gemini Nano in Chrome on every page you read. Posts, cards and emails get a badge with the deciding words highlighted. There's no cloud call and no cost, it works offline, and the page text never leaves your machine.

The hosted app opens on a ready Hidden-pay check: the commission-only program from a real compile on Gemini Nano, and five sample job posts. It flags posts that hide there is no guaranteed pay (commission-only or unpaid), and nothing else: it is not a general job-scam detector. One click checks them, and you can paste any post of your own. If your browser has no Gemini Nano, Firebase AI Logic's hybrid mode runs those checks on Gemini in the cloud instead. The app says so before you press the button, allows 15 cloud checks per browser session, and marks every result "ran in the cloud: no on-device model here" or "ran on device".

Mark a verdict wrong and it becomes a new test, and Cantrip recompiles on your device. You can share a rule by a 7-character code. The repo also holds a SwiftUI iPhone app written to port a shared program to Apple's on-device Foundation Model. It builds for the iOS Simulator but has never run on a phone, so this submission is judged on the web app and the Chrome extension only.

How we built it

Every model call goes through Firebase AI Logic.

  • Cloud compiler: getGenerativeModel with InferenceMode.ONLY_IN_CLOUD and a JSON responseSchema. It only ever sees your rule and synthetic test texts.
  • Device runtime: InferenceMode.ONLY_ON_DEVICE with responseConstraint for structured answers, and initializeDeviceModel() for the one-time download. It fails closed, so page text is never silently sent to the cloud.
  • Hybrid fallback, kept narrow: in the web app, a ready program can run with InferenceMode.PREFER_ON_DEVICE: Gemini Nano when Chrome has it, gemini-3.5-flash-lite in the cloud when it doesn't. Only for text you pick or paste, announced before the run, and capped per session. Compiling stays on the device, because a program must be tested on the model that will run it, and the extension never sends a page to the cloud. One honest caveat: the fallback runs the program tuned for Gemini Nano, unchanged, on the cloud model, so its device scores don't carry over. On 24 November it labelled the five sample posts two commission only, one unpaid and two standard pay, the labels they were written to get. That is five posts, not a tested score.
  • Where it ran: every verdict shows response.inferenceSource, so you can see the split.
  • iPhone (not run yet): the code uses the Firebase AI Logic iOS SDK with FirebaseAI.SystemLanguageModel.default and a fresh session per check. It builds for the Simulator only.
  • Firebase around it:
    • App Check
    • anonymous Auth
    • Firestore for sharing, with rules that cap size and lock edits to the author
    • Remote Config for the compiler model, the round budget, the cloud fallback model and its per-session cap
    • Hosting for the web app
  • Surfaces:
    • a web app
    • a Chrome MV3 extension with a side panel
    • a content script using the CSS Custom Highlight API
    • a SwiftUI iPhone app (builds for the Simulator, never run on a phone)

The compiler loop is plain TypeScript, with tests for the split, the repair loop, keeping the best version, holdout isolation, porting and learning from corrections.

What was built when

The repository was created on 11 November 2026, the day the contest opened. Its first two commits (the compiler, the web app, the Chrome extension and the first iPhone sources) were pushed at 7:56 AM PT, about five and a half hours before the submission period opened at 1:30 PM PT. Those two commits are the only work that predates the period. Everything below was built during it: the Xcode project for the iPhone app, a web polish pass (honest device status, narrow layout, current Chrome requirements), the Firebase project, the hosted site, the first real compiles on Gemini Nano on 14 November, and the fixes those runs forced (a fallback when the compiler model is overloaded, keeping the best program when the cloud drops mid repair, programs that stay calm on page fragments, and a sharing fix). An AI coding assistant was used throughout.

Challenges we ran into

  • Small models overfit to whatever the repair step shows them. So we hold out a third of the tests and drop any example that copies a test.
  • Gemini Nano has a tight token window and no multi-turn tools. So every check is a single self-contained prompt, clipped to 3,000 characters.
  • Splitting a real web page into checkable pieces (a job card, an email, a review) without a parser for each site.
  • The first compiler model we chose never answered on the free tier, so compiles hung for a minute. The compiler now falls back to a lighter model after 45 seconds, and the model is set in Remote Config.
  • A network drop in the middle of the repair loop threw away a better program the loop already held. Now the best program so far is kept and the compile finishes.
  • On a real job post, a paragraph of duties with no word about pay was flagged as unpaid. Programs had only been tested on whole posts. The compiler now asks Gemini for fragment tests, and the false flag went away on the same real paragraphs.
  • Gemini Nano is not deterministic. One borderline email got three different labels on three runs, so a score can move by a test between runs.
  • Firebase recommends reCAPTCHA Enterprise over reCAPTCHA v3 for new App Check integrations, so the hosted site uses reCAPTCHA Enterprise.

Accomplishments we're proud of

  • The hybrid split is the product, not a fallback: the cloud compiles, the device runs.
  • On the commission-only rule, the compiler went from 8 of 9 to 9 of 9 on Gemini Nano in 2 rounds. It scored 3 of 3 on tests the repairs never saw, using 2 cloud calls and 21 runs on the device, in 85 seconds. The harder rules took all 4 rounds: the pressure-to-pay email rule went 5 of 8, 7 of 8, 7 of 8, 8 of 8 and then scored 3 of 4 on unseen tests, and the paid-review rule went 7, 7, 7, 8 of 8 and scored 4 of 4. The data-selling rule passed 9 of 9 on the first draft. Every one of the 105 test runs reported that it ran on the device.
  • Running a compiled program made no network request at all, on localhost and on the hosted site. A check takes about 2 to 4 seconds on an M2 Pro laptop.
  • A rule travels: share it by a 7-character code and it installs on another browser. A cantrip shared from localhost installed on the hosted site, through the real Firestore rules.

What we learned

A big model that watches a small model fail on the real hardware can repair its prompt: three of our four rules needed repairs, and all three reached full marks on their tuning tests. Google's own Automated Prompt Optimization for ML Kit shows the idea works for developers offline. Cantrip does it live, for anyone, from one sentence.

What's next

  • Android, using ML Kit's on-device Prompt API.
  • A public gallery of shared cantrips.
  • Rules that act, not just flag: hide, collapse or summarise what matches.

How to test it

  • Fastest: the video shows the full loop on real hardware.
  • One click, any computer: open https://sixth-trainer-388221.web.app and press Check these 5 posts. The Hidden-pay check reads five sample job posts. Without Gemini Nano the checks run on Gemini in the cloud through Firebase AI Logic's hybrid mode, and each result says so (15 per browser session). Paste your own post checks any text.
  • The full loop, with Gemini Nano: desktop Chrome 148 or later (about 22 GB of free disk space, and 16 GB of memory or a GPU with more than 4 GB of VRAM). Press Download the model once, pick Commission-only jobs under "Your own rule", press Compile, then Try it on the examples. A compile takes about 1 to 3 minutes, and every check then runs on your device.
  • See a compile without Gemini Nano: https://sixth-trainer-388221.web.app/?preview is the compile interface with scripted answers. It says so on every screen, and no model runs in it.
  • Code without any keys: npm install && npm test runs the compiler loop, the page splitter and the page badges against fake models.
  • The extension needs its own Firebase project, because its App Check debug token can't be published. The README's "Run it" section has the steps.

Built With

  • chrome-extensions-(mv3)
  • cloud-firestore
  • firebase-ai-logic
  • firebase-app-check
  • firebase-authentication
  • firebase-hosting
  • gemini
  • gemini-nano
  • lit-html
  • remote-config
  • typescript
  • vite
Share this project:

Updates

Submission history