Dave Stanton PhD

Local First, Cloud When It Has To Be

2026-04-30

I’m building an LLM dispatch service. It’s called Conduct.

Client apps submit a job with a task type and a prompt. Conduct figures out which model should run it — local or cloud, fast model or smart model, loaded already or about to be swapped in. The client never sees the choice. The client never sees the prompt either. They just get the result.

The thing I’m building this for already exists in pieces across three different apps I’ve been working on. Each one needed its own LLM call logic. Each one had its own retry policy. Each one had its own prompt versioning problem. The dispatcher is the abstraction that should have existed before any of those apps were written.

So I’m writing it now.


Local First

The hardware is already paid for. An M5 MacBook Pro with 128GB of unified memory running Ollama can host a 70B parameter model that handles bio generation, email classification, document extraction, and SRE triage at production quality. The marginal cost per query is essentially zero.

The cloud is faster on cold starts and smarter on the hardest tasks. So Conduct routes to cloud when the task warrants it and local for everything else.

This isn’t a technical preference. For the apps I’m building this for — most of which involve client and transaction data — sensitive content stays on infrastructure the operator controls. The cloud is a fallback for tasks where the data is already public.

That distinction is the whole point.


Three Sensitivity Tiers

Every job submission specifies a sensitivity level. Conduct’s routing engine treats sensitivity as a hard constraint, not a hint.

Level Definition Routing
public Data intended for publication. Marketing copy, agent bios, public listings. Cloud models acceptable
internal Business operational data. PII, email content, task data. Local preferred, cloud acceptable
confidential Financial records, commission calculations, anything approaching regulated data. Local only, never cloud

A confidential job will never be routed to a cloud provider. Not because of fallback logic. Because the routing rule rejects it before fallback is considered.

Bio generation is internal even when the output goes on a public website — processing PII locally is the cleaner default and costs nothing extra on local hardware. Commission audits are confidential, full stop.


The Routing Engine

Each task type has a routing rule: a preferred model, a fallback model, and a sensitivity level. Conduct stores these in Postgres and updates them via API without restarting.

When a job arrives:

  1. If the request specifies a model, use it (subject to sensitivity)
  2. If sensitivity is confidential, eligible models are local only
  3. Look up the routing rule for the task type
  4. Is the preferred model already loaded? If yes, run synchronously
  5. If the preferred model needs to be swapped, evaluate priority and queue depth — swap and run, or enqueue for async
  6. If the preferred model is unavailable and sensitivity allows, use the fallback
  7. Return the result

The interesting part is step 4. When the model is already loaded, the request returns synchronously with the response in 1-5 seconds. When it isn’t, the request returns immediately with a job ID and gets processed by a Redis queue worker. Same API surface, different latency profile, fully transparent to the client.


Eval as a Side Effect

Every job execution generates eval data automatically. Same task type, different models, real production traffic. After enough jobs, you can answer “is the local model good enough for bio generation?” with actual numbers — latency distribution, token efficiency, cost per job, failure rate — instead of guessing.

GET /eval/compare?task_type=bio_generation&days=30

Returns a side-by-side comparison of every model that processed that task type. No separate benchmark runs. No synthetic test data. The benchmark is the real workload.

Manual quality scoring can layer on top later — a POST /jobs/{id}/score endpoint that accepts a 1-5 rating, enabling human-in-the-loop eval without changing the core flow. But the operational metrics come for free, day one.


Prompts Live on the Server

Clients submit a task_type. They never submit a prompt. They never see one either.

Prompts are versioned markdown files. They can live directly in the Conduct repo, or they can be loaded from a separate repo as a git submodule — useful when prompt IP needs its own access control or release cadence.

prompts/
├── shared/
│   ├── bio_generation.md
│   ├── email_classification.md
│   ├── commission_audit.md
│   └── sre_triage.md
└── clients/
    └── {client_name}/
        └── {task_type}.md   — overrides the matching shared prompt

Conduct resolves the prompt at request time based on the authenticated client and the task type. Improving a prompt is a Conduct-side change with zero client code changes. Every job execution logs the exact prompt file path and git commit hash, so any output is traceable to the exact version that produced it.

Prompts are IP. They shouldn’t be scattered across client codebases.


Observability From Day One

Every job emits an OpenTelemetry span. Routing decisions are span events. Provider calls are child spans. Token counts, costs, and latency are span attributes.

Conduct exposes a Prometheus endpoint that gets scraped by Grafana Alloy and forwarded to my LGTM stack. The dashboard surfaces job throughput by model, cost by client app, latency distribution, queue depth, model swap frequency, fallback rate. Same pattern as Watchtower, applied to a new service.

The dashboard is also the live eval surface. The two aren’t separate concerns.


Static Retry Now, Triage Model Later

Each provider gets its own retry policy. Tenacity handles exponential backoff for Anthropic rate limits, longer timeouts for Bedrock cold starts, and immediate failure for Ollama timeouts so the fallback logic can take over.

Different failures get different responses:

Failure Response
Ollama timeout Fall back to cloud if sensitivity allows
Ollama model not loaded Enqueue for worker to swap and retry
Anthropic rate limit Exponential backoff, retry same provider
Anthropic unavailable Fall back to local model
Bedrock cold start Retry with longer timeout
All providers failed 503 with retry-after

That’s v1. The static rules cover the obvious failure modes.

For v2, a small always-resident local model (3B-8B parameters, ~6GB memory) watches the failure signals and makes the routing decision. Same context the static rules see — error type, available models, queue depth, client priority, sensitivity — but the model can weigh them. Did this combination of signals lead to a successful retry last time? Use that. Did it lead to wasted compute? Don’t.

The triage model never sees prompt content. Only operational metadata. It runs on essentially free compute since the hardware is already paid for. LLM all the things.

The v1 retry interface is designed so the triage model plugs in without a refactor.


What This Unlocks

Multiple apps I’m building all need this. Each was about to grow its own version. Now they share one.

A real estate brokerage platform routes AI through Conduct so client data stays local by default. Bio generation runs on the local model instead of OpenAI. Email classification too. The cloud only sees jobs flagged public — and even then, only if the local fallback isn’t sufficient.

A side project for SRE incident triage routes through Conduct because the same dispatch logic applies — operational metadata, fast local model, escalate to a smarter cloud model when the diagnosis is hard.

A research tool I haven’t shipped yet routes through Conduct because the cost model only works if local is the default and cloud is the exception.

Different apps. One dispatcher. The IP that matters — prompts, routing rules, eval data, sensitivity policy — lives in one place.


What I Didn’t Build

Multi-machine worker distribution. One M5 is enough. Adding more machines is a problem for when one isn’t.

Streaming responses. Batch only for v1. The use cases I’m building for don’t need token-by-token streaming. When one does, it’ll be a route-level change, not an architecture change.

Fine-tuning or model training. Not Conduct’s job. The dispatcher routes to whatever models exist. Training is a separate concern with its own pipeline.

Billing. Usage tracking is the foundation. Per-client cost attribution per job is captured in Postgres and exposed via the metrics API. A billing layer can read from that whenever it needs to. No reason to build it before there’s a reason to.


Why This Pattern Matters

The big-picture argument is this: most AI integrations have been backwards. The default path is to wire every app directly to OpenAI or Anthropic, scatter prompts across codebases, and pay metered cloud costs for every query — including the ones that didn’t need to leave the building.

Inverting that — local first, dispatcher in the middle, cloud as fallback — changes the cost model and the data sovereignty story simultaneously. The hardware is already paid for. The marginal cost of a local query is electricity. The cloud is there for the genuinely hard cases.

For most of the work most apps do, the local model is good enough. Conduct is the thing that makes “good enough” the default routing decision instead of an optimization you have to think about.


Conduct is open source and on GitHub: gotoplanb/conduct. Early days — I’m building it against real workloads and the API surface will move until the use cases settle.

If you’re running into the same dispatch problem across multiple AI-using apps and want to compare notes, get in touch.