# Raphael Bernardo

**Senior AI / LLM Systems Engineer · Agents, Orchestration & Local Inference**
Ex-Uber (contract) · ten-plus years of production engineering, now building the systems that run AI agents: multi-provider routing, agent tooling over MCP, retrieval and knowledge graphs, evaluation gates, and GPU inference on my own machine fleet.

Rio de Janeiro, Brazil (GMT-3) · Brazilian + Portuguese (EU) dual citizen
Languages: Portuguese (native), English (fluent), Spanish (intermediate)
Offshore B2B contractor from Brazil, invoicing through my own company (CNPJ). Overlaps a full US Eastern working day.
+55 (21) 98885-6697 · raphaelbgr@gmail.com
github.com/raphaelbgr · linkedin.com/in/raphaelbgr · raphaelbgr.com

---

## Summary

Senior engineer who designs and operates AI systems, not only calls to them. I run a multi-provider LLM dispatch mesh across my own machine fleet (CUDA, Apple Metal, Linux, Windows, macOS), with cost-aware routing over 8 providers and 22 models, agent tooling exposed over MCP, and every external model's output reviewed before it is accepted. On the same fleet I serve local models behind an OpenAI-compatible coordinator that admits a request only if the model and its KV cache fit a node's free VRAM. I build retrieval and knowledge-graph pipelines, computer vision and speech services, and LoRA fine-tuning for video, and I build agent work to be verifiable: written completion gates, execution-trace contracts, and closed-loop evaluation against a running app.

That AI work sits on ten-plus years of production software: Uber's Maps SDK in JNI/C++, OTT streaming platforms with 4K multi-DRM playback, and apps I publish myself on Google Play and the App Store.

---

## AI Engineering

Systems I designed, built and run on my own machines. Nothing in this section lives in a client codebase.

### Orchestration and model routing
- **Dispatch mesh:** one HTTP daemon per machine with peer auto-discovery, WebSocket output streaming and full job telemetry, exposed to the orchestrating agent as 15 MCP tools.
- **Cost-aware routing** over 8 providers and 22 models in 6 tiers: local models (Ollama, LM Studio), OpenRouter, Z.AI (GLM), Moonshot (Kimi), Anthropic, OpenAI and xAI. Rate-limit backoff, per-provider cooldowns and capability matching are applied in order; flat-rate providers are marked serial-only so a parallel fan-out cannot exhaust a subscription's concurrency limit; frontier tiers are opt-in, never bulk.
- **Review before acceptance:** every external model's output is checked against the brief (every changed line traced, tests actually run) before it is accepted, with up to two retries and then escalation to a stronger tier.
- **Encrypted job transport** keyed off the existing SSH identity: RSA-OAEP + AES-256-GCM, fresh key and nonce per message.
- **Command Center:** a Node.js daemon on every fleet machine for signed REST/WebSocket remote execution, running coding-agent CLI sessions as jobs, with token/cost analytics, peer discovery, self-update and a dashboard.

### Agents, tools and control surfaces
- **Skills system for coding agents:** 75 global skills under three scoping tiers (global, project, archived), an auto-creation gate (a procedure must recur three times; search first; improve, then chain, then build), and a ranked search over the whole corpus before any capability is declared missing.
- **Agent roles:** planner, executor, evaluator and monitor agents for multi-step work; a local LLM that supervises a headless coding agent, detects when it stops and decides the next action.
- **Chat as control surface:** a Slack gateway (Bolt, Socket Mode) that turns messages into headless agent runs, with a serial queue per project, timeouts, a post-hoc reviewer and an SQLite session store, plus a scheduled daily briefing job. Telegram alerts for long-running jobs (crash, start, plateau), env-gated so offline runs stay silent.
- **Fleet session manager:** discovers and resumes agent sessions across five machines from one place (terminal UI, web UI and desktop window over a REST + WebSocket API).
- **Agent-facing products:** a live pay-per-call API that AI agents call and pay for per request (x402, HTTP or MCP tools), with a durable job store so a lost response is recovered without charging twice.

### Retrieval and knowledge graphs
- **Fleet knowledge graph:** 3,489 nodes and 83 communities extracted from 2,018 files across six machines, with a reproducible pipeline (harvest, merge, chunk, extract, build) and graph queries for agents.
- **RAG research agent** (Agno) with parallel web search and a context limited to the latest refinements plus a knowledge base, so it runs on small local models.
- **Embedding search:** FAISS face-embedding search over a personal media archive; embedding-based ranking of CVE descriptions to prioritise fuzzing targets.

### Evaluation and completion gates
- **Written completion gates:** substantial agent work is done only when a ledger of runnable checks (command plus expected-output pattern) passes, with a lint step and re-verification; I documented the threat model for agent-run checks.
- **Closed-loop evaluation on my own TV app:** an on-device HTTP diagnostic surface with 149 named test routines returning structured pass/fail; an agent drives the app, reads what the screen and the event stream actually show, and evaluates against the contract.
- **Benchmark-gated model adoption:** for generative video, a fixed four-scenario benchmark on the real identity, scored before any model is adopted, with a manifest per run so winners are reproducible.

### Inference and GPU operations
- **Local inference coordinator:** an OpenAI-compatible front door for a CUDA node (RTX 3080 Ti) and an Apple M4 node: request queueing, load-balancing, grouping by model for warm reuse, auto-pull of Hugging Face GGUF models, and admission control that rejects a model with HTTP 507 when weights plus KV cache fit no node, instead of silently falling back to CPU.
- **Fitting models to hardware:** a per-node fitter that picks the best quantization and largest context that fit each GPU; an LLM gateway in front of two nodes (later retired in favour of the coordinator).
- **Rented GPU:** a llama.cpp model on a cloud GPU behind an SSH tunnel with a 131,072-token context, the agent runtime capping input at 114,688 tokens and summarising history at 98,304; the agent itself runs in a Docker sandbox.
- **VRAM accounting:** every GPU allocation is registered before it happens (measured size, purpose, expected release); stale or overdue claims are detected and the exact holder is reported. Services lazy-load and auto-unload after 30 idle minutes.

### Computer vision, speech and fine-tuning
- **Face and person recognition:** InsightFace on ONNX Runtime GPU with FAISS embeddings, distributed across GPU workers; local vision-language captions (Qwen2.5-VL) for photos and video keyframes.
- **Vision grounding:** a local server that maps an image plus a natural-language query to boxes or points (NVIDIA LocateAnything-3B), with a pinned model revision, bytes-only input and model output treated as data, never as instructions.
- **Hand-gesture control:** MediaPipe Gesture Recognizer (TensorFlow Lite) running in the phone's browser on WebAssembly/GPU, streaming 21 hand landmarks and gesture labels at about 30 Hz over WebSocket to a tvOS Swift package, so a phone becomes a multiplayer motion controller with no install.
- **Speech recognition and source separation:** faster-whisper (large-v3-turbo) and Demucs vocal/instrument separation in a queued service with leases, heartbeats and idempotent revisions; 630 audio files transcribed with faster-whisper on one RTX 3080 Ti.
- **LoRA fine-tuning for video:** an identity workspace with dataset preparation and validation, still-image LoRA training (Flux) and image-to-video LoRA training run locally (Wan 2.2), driven through ComfyUI workflows.

### Observability and fleet operations
- **Trace-first debugging standard:** a language-neutral trace-contract spec (JSON Schemas, a cross-language conformance oracle, golden cases) and an agent plugin whose hook blocks completion while the reference graph is stale; a Python library that turns decorated steps into a JSONL trace and a contract diff an LLM can read.
- **Process hygiene for agents:** every spawned process is tagged, registered with an owner and an expiry before it runs, and reaped in the same turn; long jobs write heartbeat files and checkpoint each unit so they can pause, crash and resume exactly where they stopped.
- **Manifest-driven deployment** across five machines under launchd, systemd and Task Scheduler: each app declares install, launch and health; deployment is a git push, with a test gate and rollback.

**Stack:** Python, asyncio, FastAPI, Node.js, TypeScript, MCP, OpenAI-compatible APIs, Ollama, LM Studio, llama.cpp, LiteLLM, OpenRouter, Agno, FAISS, InsightFace, ONNX Runtime, MediaPipe, faster-whisper, Demucs, ComfyUI, PyTorch, CUDA, Apple Metal, SQLite, PostgreSQL, Docker, Slack Bolt, Telegram Bot API, Tailscale, GitHub Actions, Fly.io, Cloudflare.

---

## Professional Experience

### Nexstar Media Group, Inc. — Senior Fire OS / Android TV Engineer
**Aug 2025 – Present · Contract · Full Remote**

Multi-brand OTT streaming platform framework for Fire TV and Android TV, on the platform engineering team.

- Run a client-approved agent-driven delivery workflow end to end: one command starts it, an agent picks up the tracker issue with its acceptance criteria, works the change on an isolated branch, runs the test suite alongside agent-driven end-to-end checks against a running build, and opens a GitHub pull request carrying the issue context and test evidence. GitHub Actions runs the pipeline; a second model audits the diff against the original request before anything is reported done.
- Contributed to the architecture of an enterprise OTT streaming framework (MVVM + Clean Architecture, plugin-based integrations); 5 specialised Media3 / ExoPlayer implementations; DRM-protected streaming (Widevine, PlayReady) with server- and client-side ad insertion.

### FreeCast, Inc. — Android / Android TV / Fire OS Engineer
**Mar 2021 – Jul 2025 · Contract · Part-time, EST hours · Full Remote**
- Led the Java-to-Kotlin migration with Clean Architecture; owned DRM, EPG, tuner orchestration, transcoding and multi-device streaming end to end; AI-assisted development on the migration and on test coverage, later with coding agents as a primary development method and automated verification in CI before review.

### Claro TV+ — Android TV / Fire OS Engineer
**Apr 2024 – Dec 2024 · Freelance via Global Hitss · Part-time · Full Remote**
- Greenfield Android TV / Fire OS app for one of Brazil's largest pay-TV operators: 4K DASH/HLS with multi-DRM, a shared Kotlin Multiplatform data layer for Android, webOS and Tizen; AI-assisted code generation and review across the build.

### Uber Technologies — Android Engineer, Maps SDK team
**May 2021 – May 2022 · Contract via Matchpoint Solutions · PST hours · Full Remote**
- Maps SDK module in JNI / C++ inside Uber's RIBs architecture and internal monorepo, across a 10K+ engineer codebase; shipped to Uber Rider, Uber Eats and Uber Driver.

### Earlier
Super Revendedores, Android Engineer (2018–2021; AWS SQS/SNS order processing) · Concrete / Accenture, Jr. Android Engineer (2016–2018; Minha CVC, 1M+ downloads) · PraPagar, Jr. Android Engineer (2015–2016) · IBM Brasil, intern (2014).

---

## Products and Publications

- **Book: Automate Your Work Once and for All** — a practical guide to AI-assisted work. Apple Books: https://books.apple.com/us/book/id6814453573 · Google Play: https://play.google.com/store/books/details?id=7_wOEgAAQBAJ
- **RugShield** — live pay-per-call API for AI agents (Python, FastAPI, x402, MCP, Fly.io): https://getrugshield.com/
- **Archive — Home Video Player** for Apple TV and Android TV: https://apps.apple.com/us/app/archive-home-video-player/id6781049173 · https://play.google.com/store/apps/details?id=com.arquive.tv
- **IPTV Player** for Apple TV, iPhone and iPad: https://apps.apple.com/us/app/iptv-player-own-sources/id6810480572
- **Beer Price Calculator** for Android and iPhone: https://play.google.com/store/apps/details?id=br.com.raphaelbgr.preoscerveja · https://apps.apple.com/us/app/calculadora-de-cerveja/id6780996197

---

## Technical Skills

**AI & LLM systems:** multi-provider routing and tier escalation, agent architectures (planner / executor / evaluator / monitor), MCP server and tool design, coding-agent skills and workflows, RAG, embeddings, knowledge graphs, evaluation and completion gates, prompt engineering, LoRA fine-tuning (image and image-to-video).
**Inference & GPU:** Ollama, LM Studio, llama.cpp, LiteLLM, GGUF quantization, KV-cache-aware VRAM admission, CUDA and Apple Metal hosts, cloud GPU rental.
**Vision & speech:** InsightFace, FAISS, ONNX Runtime, MediaPipe (TensorFlow Lite), Qwen2.5-VL, faster-whisper / CTranslate2, Demucs, ComfyUI.
**Languages:** Python, Kotlin, Java, Swift, C++, TypeScript, JavaScript, SQL.
**Backend & infra:** FastAPI, asyncio, Node.js, REST, WebSocket, SQLite, PostgreSQL, Docker, GitHub Actions, Fly.io, Cloudflare, Tailscale, launchd / systemd / Task Scheduler.
**Mobile & TV (foundation):** Android SDK, Jetpack Compose, Media3 / ExoPlayer, Kotlin Multiplatform, NDK / JNI, iOS and tvOS with SwiftUI, HLS / DASH, Widevine / PlayReady.

---

## Education

**Instituto Infnet — Rio de Janeiro · 2013 – 2018**
B.S. in Computer Engineering.
