Dave Stanton PhD

Conduct

Multi-tenant LLM dispatch โ€” local or cloud, by task type

v0.1 ยท untagged GitHub →

Conduct's mascot, a hermit crab in a tuxedo holding a conductor's baton.

I had three apps that each called a model. Each one had its own call logic, its own retry policy, and its own prompt versioning problem. The dispatcher is the abstraction that should have existed before any of them were written.

Conduct is that dispatcher. A client submits a job with a task_type and its inputs. Conduct picks the model, local or cloud, runs it, and records what happened. The client doesn’t need to know which model ran, and it never holds the prompt.

I wrote up the original design in Local First, Cloud When It Has To Be in April. This page is what it turned into.


What a job looks like

curl -X POST -H "Authorization: Bearer $CLIENT_KEY" \
  -H "Content-Type: application/json" \
  "$CONDUCT_BASE_URL/jobs" \
  -d '{"task_type": "dad_joke", "prompt": "a joke about tuxedos"}'

Behind that call, a routing rule for dad_joke names a preferred model, a fallback, a sensitivity floor, and a list of shadow models. The rule lives in Postgres and changes live with PUT /routing/dad_joke. No restart.

A cloud target answers synchronously. A local target returns 202 and a poll URL, because the worker owns Ollama and model swaps, and I don’t want a request handler coordinating a 70B load.

The same jobs can come from a phone. Conduct is its own OAuth 2.0 authorization server and exposes an MCP endpoint, so the Claude apps can add it as a custom connector. Six tools: list task types, create a job, get a job, list jobs, list a job’s shadows, and submit an eval. The iOS quickstart walks through firing a dad joke from Claude on a phone, pulling every model’s attempt side by side, and scoring the best one without leaving the chat.


Decisions worth explaining

Sensitivity is a floor, not a hint. Every rule and every job carries public, internal, or confidential. A client can be stricter than the rule, never looser. A confidential job has its cloud options stripped before the request reaches a provider, so no fallback path and no misconfigured client can send it to Anthropic.

The benchmark is the real workload. A rule can carry shadow models that replay the same prompt on a sample of real jobs, on a low-priority queue, with responses that never go back to the client. The rollup puts the production model and its shadows in one table: cost per job, latency, failure rate, average score. Cloud shadows can carry a daily spend cap.

The router judges itself. A judge job is an ordinary job whose work is scoring another job. Pointwise against a rubric, pairwise head to head, or a panel of models. Pairwise runs twice with the order swapped and records a tie if the verdict flips. Panels exclude jurors from the producer’s model family. I wrote about this in The Flywheel.

Primitives, no hooks. The judge doesn’t fire when a job completes. You submit it. Its verdict writes back to the judged job only if the caller asks. Media chaining works the same way: you pass job IDs, Conduct resolves them.

Prompts live on the server. They started as versioned markdown files. In May they moved into Postgres, and every edit appends a version row first, so an old job stays tied to the exact text that produced it.

Local is the workbench. Cloud is the storefront. The local install is where research happens. The cloud deploy, ECS Fargate with Bedrock, would serve user-facing task types with the same routing and eval core. Some capabilities are local-only by design and never ship to the cloud.


Where I changed my mind

In April, under “What I Didn’t Build,” I wrote:

Fine-tuning or model training. Not Conduct’s job.

By June, scored traffic exported as SFT and DPO training JSONL. Then came a code generation loop: Rust projects compiled in a build sandbox and scored on compilation, golden and property tests, mutation testing, structural regressions, and hallucinated dependencies, all rolled into a composite that produces preference pairs.

Then #45 added a dpo_fine_tune task type. It’s a thin provider over an MLX training sidecar, so the training itself still happens outside Conduct. But a resulting checkpoint routes like any other local model, and Conduct does the memory work around the run. It unloads the roughly 37GB of resident serving models before training and re-pins them afterward, whether training succeeds or fails.

The line moved from “Conduct doesn’t train” to “Conduct doesn’t contain a trainer.”


Memory is the real scheduler

Everything runs on one MacBook Pro with 128GB of unified memory. Most of the bugs worth telling are about that number.

Music generation crashed the machine. The ACE-Step provider sent duration at the top level of the request. The server only reads settings from an audio_config object and silently drops the rest. So the model picked its own length, 215 seconds in the case I caught, and a 3.5-minute diffusion latent spiked about 80GB. It ran right after a video job, with ComfyUI still holding the video model. The combined peak went past 128GB and took the box down mid-generation.

The fix bounded the clip at 30 seconds by default. Generation time dropped from 67 seconds to 37, and the lowest free memory during a run went from 33% to 62%.

Only one model would stay loaded. Newer Ollama versions default each model’s context window to its maximum trained length, 131k to 262k tokens. At that length the KV cache for a 3B model is around 15GB, so loading a second resident model evicted the first. That broke cross-model routing and shadow fan-out. Bounding the context at 16,384 tokens let three residents sit together in about 22GB.

And then they didn’t stay loaded. The worker pinned residents only at boot, so any Ollama restart evicted the set until the worker restarted too. Now a reconcile loop checks every 30 seconds and re-pins anything missing. The test was killing ollama serve. All three residents were back within one tick.


Stack

  • FastAPI for the API, Postgres for jobs, rules, prompts, and scores, Redis with RQ for the queue. One container image for the API and the worker.
  • Providers: Ollama locally; Anthropic and Bedrock in the cloud; ComfyUI for image and video, ACE-Step for music, Piper for speech, and ffmpeg for muxing.
  • Server-rendered UI with HTMX, Alpine, and Tailwind for browsing jobs, reviewing shadows, managing clients, and minting connectors. A conduct CLI covers the same ground.
  • OpenTelemetry traces, logs, and metrics to Watchtower, with trace context carried across the queue hop.
  • SonarQube as a quality gate. A September pass took coverage from 86% to 97%, with 887 tests passing.
  • Terragrunt for a multi-region AWS deployment. It’s a skeleton and hasn’t been applied.

History

There are no tagged releases. The package version is still 0.1.0. These are the milestones from the commit log.

Date What landed
Apr 29 Initial implementation, containerized, with the git SHA baked in for prompt provenance
May 2 Shadow jobs and parallel small-model fan-out
May 15 Local UI, prompts moved to Postgres, the conduct CLI
May 23 OAuth authorization server and remote MCP server
May 30 Per-client Anthropic keys, encrypted at rest
Jun 2 AWS Bedrock provider
Jun 7 Image, video, audio, and mux task types
Jun 17 LLM-as-a-judge, named score dimensions, SFT and DPO export
Jun 19โ€“22 Code generation eval loop and the dpo_fine_tune task type
Jun 23 Bounded context and the self-healing resident set
Sep 2 Checked against my OAuth conformance suite, and corrected it
Nov 4 Claude Haiku 5.5 support

Conduct was the second implementation checked against that conformance suite. The suite’s first draft said a token’s principal must never be derived from the client record. Conduct derives it, and here that’s safe, because each OAuth client belongs to exactly one client app. So the rule was rewritten around the property instead of the mechanism.


What it isn’t

  • Not a trainer. It exports training data and coordinates around a run. The training happens in a sidecar.
  • Not multi-machine. One worker on one Mac. That’s a deliberate trade, and it’s why every local job goes async.
  • Not streaming. Jobs return whole results.

What’s next

The v1 failure handling is static rules. The v2 handler, a small always-resident local model reading operational metadata and never prompt content, has its prompt written and its interface in place, and still raises NotImplementedError.

The other thing I’m watching for is the one I named in June: a fine-tuned model from this loop outperforming the production model it was trained against.

Conduct is used by Watch for handoff briefs and drafted RCAs. It also made the art for Same Article, Different Page.

The code is MIT-0 licensed. Take whatever’s useful.