Inspiration
PoorBoyAI ("PB") is a live AI agent who runs a real crypto community on Telegram — answering members, running contests like Turkey Run, tracking raids, and teaching the house's own games and tools. Until this weekend, PB only existed inside Telegram. If you weren't in the group, you couldn't ask him anything.
We wanted anyone, anywhere, to be able to ask PB a question — and we wanted the answer to be generated on the visitor's own device whenever possible: private, instant, free to run, and working offline. Firebase AI Logic's hybrid inference is exactly that shape, so we built PB a home on the open web.
What it does
Ask PB is a one-page web app. Type any question — about PoorBoyAI, about crypto, about anything in the world — and PB answers in his own voice.
Every answer carries a small badge that says which brain wrote it:
- On-device · Gemini Nano — the answer was generated locally by Gemini Nano in the visitor's Chrome. The question never left their machine.
- Cloud · Gemini — the answer came from cloud Gemini through the same Firebase AI Logic call.
Underneath the badge, when a question needs a current fact — a price, a score, today's news — the answer also lists the real pages PB consulted, under the line "PB checked:", so anyone can verify the answer against its sources.
Ask PB answers PoorBoyAI questions from a distilled version of the fact sheet PB uses in Telegram (what PoorBoyAI is, the $PBAI and $PBLP tokens on Base, the Turkey Run contest, the Streets of Crypto game, plan pricing), and it answers general questions — science, history, math, recipes, writing help — without steering anyone back to our community. Ask him anything; he answers it.
How we built it
Hybrid inference (the core of the entry). The app uses the Firebase JS SDK's AI Logic (firebase/ai) with a Google AI backend. The main model is created with InferenceMode.PREFER_ON_DEVICE, so Firebase AI Logic tries Gemini Nano on the visitor's device first — through Chrome's built-in Prompt API — and falls back to cloud Gemini automatically when on-device isn't available. Answers stream in with generateContentStream, so they type out live.
The lane badge is real, not decoration. The SDK reports an inferenceSource on every streamed chunk and on the final response (on_device or in_cloud, Firebase JS SDK v12.5.0+). The badge is set from that value. When the SDK serves from the device, the badge says so; when it falls back, the badge says that. Judges don't have to take our word for the hybrid routing — every answer labels itself.
App Check. AI Logic is protected with Firebase App Check using the reCAPTCHA Enterprise provider (Fraud Defense). Enforcement is on, and we proved it from outside the browser: a Node probe that reached the AI Logic backend without a valid App Check token was rejected with a 401.
One prompt, two brains. Both lanes share one system context: PB's voice and a compact PoorBoyAI fact sheet, trimmed to fit Gemini Nano's small on-device context window. The same PB who answers in Telegram answers on the web — house questions get house-accurate answers on either lane, and PB is under a standing honesty rule: never invent a PoorBoyAI price, date, or address, and never claim to have checked something he didn't check.
PB checks the live web himself — with our own search, not a vendor's. The built-in grounding tools available on this backend never actually grounded an answer in our testing (more on that under Challenges), so we built the lookup ourselves, in-house:
- Before answering, the app decides whether a question needs a current fact. If it does, the app fetches live results from our own search worker — pb-ask-search, a small Cloudflare Worker we wrote for this project (its source is in the public repo under search-worker/). The worker reads public search result pages (DuckDuckGo and Bing) and parses them itself. No vendor search API, no search API key, no third-party grounding service.
- The fetched snippets are handed to whichever lane serves the answer — on-device or cloud — as context, and the model answers from those pages.
- The app then lists the top pages it actually fetched under the answer as "PB checked:" — real links a judge can click.
- The search fails open and honest: if the fetch comes back empty, PB answers from his own knowledge and says he couldn't verify the live fact, instead of inventing one.
Because the search is the app's own machinery and runs before the brain is picked, even the small on-device model can answer today's questions from today's pages.
Put to the test. Before calling this done, we ran PB through a 22-question "oddball battery" in a real browser — general knowledge, recipes, history, word problems, and math with traps in it (the classic sheep riddle, a price that rises 10% then falls 10%). He passed 22 out of 22, including both live questions, with sources shown: the current price of ETH (answered in a tight range, citing CoinMarketCap, Yahoo Finance, and CoinDesk) and the winner of the 2026 World Series (the Milwaukee Brewers over the Tampa Bay Rays in five games, citing Wikipedia and MLB.com).
What was built during the hackathon window. PoorBoyAI the Telegram agent already existed. Everything in this entry is new and was built in the window: the Ask PB web app itself, the Firebase project and AI Logic wiring, the hybrid on-device/cloud routing with the inference-source badge, App Check enforcement, the in-house pb-ask-search worker and the search-first answering flow, the web fact sheet, and the public MIT-licensed repo with CI auto-deploy to Firebase Hosting on every push.
Challenges we ran into
- Grounding that wouldn't ground. We first wired the SDK's built-in search grounding and tested four Gemini models against this project's AI Logic backend. One answered reliably but never searched at all — and once confidently invented a price and claimed it had checked live. One was closed to new users on this project. One was unreachable. One tried to call the search tool and the backend rejected the call as malformed. Rather than ship a badge that lies, we built our own search worker (above) — which turned out better anyway: it's ours, it's inspectable, and it works for the on-device lane too.
- Nano's small context. The on-device model can't carry PB's full Telegram knowledge. We distilled the fact sheet down to what fits, and let live search cover the rest.
- A hang in device init. Calling the on-device initialization on the plain cloud model stalled asks forever on a "checking on-device" state. Device init now runs only on the hybrid model; the cloud lane starts clean.
- A stream that could stall forever. A streamed answer that stalled mid-flight left the waiting state spinning with no deadline. Streamed answers now race a 15-second timeout: text already on screen is kept as the answer, and a stalled ask ends in a plain try-again state instead of an endless spinner.
- Stale-cache confusion. Firebase Hosting's default one-hour cache briefly served the very first build to real visitors after we'd already shipped fixes. Custom cache headers (no-cache for the page, immutable for hashed assets) ended that.
Accomplishments that we're proud of
- A working hybrid app where the lane badge is the SDK's own inferenceSource — the routing is visible and verifiable on every single answer.
- A live-fact pipeline with zero vendor search dependencies: our own worker, our own parsing, sources printed under the answer.
- 22/22 on a deliberately tricky question battery, in a real browser, including both live questions with clickable sources.
- App Check enforcement proven from outside the browser (401 without a token), not just switched on.
- The whole thing — app, search worker, CI deploy — is open source under MIT in the public repo.
What we learned
Hybrid inference changes what "the app" even is: the same question can be answered by two very different brains, and the product work is making that invisible when it should be (same voice, same facts, same honesty rules) and visible when it matters (the badge, the sources). We also learned that a small on-device model punches far above its weight when the app does the fetching for it — retrieval doesn't have to come from the model vendor to be real.
What's next for Ask PB
Ask PB is staying up after the hackathon as PoorBoyAI's public front door. Next: bring the same search-first answering to PB's Studio tools (live references and fact-checked scripts and captions), keep shrinking the fact sheet so the on-device lane carries more of the house on its own, and graduate the lessons PB learns on the web back into the Telegram agent he started as.
Built With
- cloudflare-workers
- firebase-ai-logic
- firebase-app-check
- firebase-hosting
- firebase-js-sdk
- gemini
- gemini-nano
- typescript
- vite