>- Project-kickoff rubric for the self-host vs managed-cloud decision — when is running your own inference engine / LLM platform worth the ops cost vs paying per-token for a managed API? Decide on two axes — VOLUME (a cost-crossover slider) and COMPLIANCE (a hard gate). Use at kickoff when choosing where to run inference, or when cost / data-residency pressure forces a re-evaluation.
npx skills add https://github.com/agentsope/SkillAlchemy --skill agentsop-selfhost-decision
> Overlay, not a deep dive. This skill answers *where to run* (self-host vs managed), not *which engine* ([[agentsop-llm-engine-selection]]) or *how to build the app* ([[agentsop-dify]]). It fires first, at kickoff, and hands off to those once the side is chosen.
> This rubric exists because the loud reflex — *"running our own is cheaper / more serious"* — is true only above a volume crossover, and only if you have the ops capacity, and only if compliance hasn't already forced your hand. The job is to evaluate the gate before the slider, and to cost the ops burden, not just the GPU.
判断公式:
> Self-host trades ops burden for control + unit-cost-at-scale. Managed trades $/token for zero ops. The crossover is a function of two axes: volume and compliance.
COMPLIANCE (a GATE — binary, evaluated FIRST)
│
managed FORBIDDEN │ self-host (or in-region managed) MANDATORY
──────────────────┼──────────────────────────────────────────► VOLUME
│ (a SLIDER —
managed allowed │ below V*: managed cheaper continuous
│ above V*: self-host cheaper crossover)
│ (IF utilization high + ops capacity exists)
V*. Below it managed wins; above it self-host wins — *conditionally*.managed_cost(V) = V × $/token_managed
selfhost_cost(V) = (GPU + ops_labor + infra_fixed) + V × $/token_marginal
V* = (GPU + ops_labor + infra_fixed) / ($/token_managed − $/token_marginal)
ops_labor — a fraction-of-FTE DevOps cost (backups, monitoring, upgrades, on-call). Cost it explicitly; it is rarely zero.Self-host volume isn't free of limits. A platform has a per-replica ceiling — Dify's is ~10 QPS/pod, gated by per-node DB queries [dify §6.2]; vLLM's is gated by KV-cache occupancy + preemption [vllm OP-5]. To hit volume V you need replicas = peak_QPS / ceiling, and that replica count feeds back into the GPU term of V*. High volume can need so many replicas that the crossover moves against you.
The decision is not permanent. Keep a thin OpenAI-compatible API surface on both sides so flipping managed↔self-host is a config change, not a migration. Define the flip trigger up front (spend > V* for N months; new compliance rule; lost ops owner). Re-evaluate quarterly — both your volume and the price/quality frontier move (May 2026 stamp; re-measure).
[Step 0] Confirm this is a "where to run" question
├─ "which engine?" → [[agentsop-llm-engine-selection]], stop
├─ "how to build Dify?" → [[agentsop-dify]], stop
└─ "managed vs our own?"→ continue
[Step 1] COMPLIANCE GATE first (OP-2) ── binary, overrides cost
├─ Regulated / residency / air-gap / contract boundary?
│ ├─ YES, and no managed in-region/BAA/VPC tier → self-host MANDATORY → Step 3
│ └─ YES, but a compliant managed tier exists → managed re-opened → Step 2
└─ NO → Step 2
[Step 2] VOLUME SLIDER (OP-1) ── compute the crossover
├─ Estimate monthly volume (reqs × tokens)
├─ managed_cost = V × $/token
├─ selfhost_cost = (GPU + OPS_LABOR + infra) + V × marginal ← include ops!
├─ V* = fixed / (managed_$tok − marginal_$tok)
├─ V below V* → managed wins → Step 5 (plan fallback)
└─ V above V* → self-host candidate → Step 3
[Step 3] HONEST OPS-CAPACITY CHECK (OP-3) ── the trap door
├─ DevOps / SRE / on-call owner exists? ─ no → managed wins anyway → Step 5
├─ Can run external Postgres/Redis/VectorDB + K8s? ─ no → managed or hire first
└─ yes → Step 4
[Step 4] THROUGHPUT-HEADROOM CHECK (OP-4) ── re-feed into cost
├─ replicas = peak_QPS / per-replica_ceiling (~10 QPS/pod Dify; KV-bound vLLM)
├─ Re-run V* with the TRUE replica count (GPU term grows)
├─ still favorable → self-host → Step 5
└─ flipped unfavorable → reconsider managed or HYBRID (Step 4b)
[Step 4b] HYBRID option (OP-5) ── if volume is spiky or tiered
└─ self-host the steady floor + burst/overflow to managed; or
compliance/premium → self-host, bulk → managed
[Step 5] PLAN THE FALLBACK (OP-6, OP-7)
├─ Lock-in / license audit (same-image? egress? contract minimums?)
├─ Thin OpenAI-compatible abstraction so the flip is config, not migration
├─ Define the bidirectional flip trigger
└─ Schedule quarterly re-evaluation
> The ordering is load-bearing: gate (Step 1) before slider (Step 2) before capacity (Step 3) before throughput (Step 4). A compliance NO short-circuits everything; a missing ops owner short-circuits a favorable GPU cost.
V = reqs/mo × (in+out tokens); managed = V × $/tok; selfhost = (GPU + ops_labor + infra) + V × marginal; solve V* = fixed / (managed_$tok − marginal_$tok). Place projected V relative to V*. Include the ops-labor term — do not assume it's zero.V* and which side projected volume sits on, with ops labor explicit.2+N CPU cores per N GPUs or the API server bottlenecks before the GPU [vllm Anti-pattern 6].replicas = peak_QPS / ceiling, then re-feed that replica count into OP-1's GPU+ops term. If the replica count is large, re-run the crossover; the "cheaper at scale" assumption may not survive.V*.num_requests_waiting / KV occupancy / preemption [vllm OP-5].Situation: A regional healthcare startup runs a doc-grounded copilot. Volume is ~50k requests/mo — well below the cost crossover V*, where a managed API ($/token) would clearly be cheaper than buying and running a GPU. But patient data is bound by data-residency + air-gap rules.
Tension:
Resolution heuristic:
V* still tells you how *small* you can go).Evidence: [dify Case 3 决策矩阵 (合规/数据驻留, air-gapped → self-host)]; [vllm OP-4 caveat (multi-tenant privacy / cache salting)].
Situation: A team is choosing between Dify Cloud Pro/Team ($59–159/mo) and self-deploying Dify on Docker. The pitch for self-host: "we own the data, and at scale it's cheaper than a subscription."
Tension:
V* against you (OP-4).Resolution heuristic:
V* with the replica count needed to clear ~10 QPS/pod.> Net: self-host Dify is worth the ops cost only above V* *and* with real ops capacity *and* after the replica-count math survives. Below any of those, the $59–159/mo subscription is the rational choice.
Evidence: [dify Case 3 决策矩阵 + 实操要点]; [architjn.com/blog/dify-cloud-pricing-plans-free-tier-when-to-self-host]; [dify §6.2 ~10 QPS/pod]; [dify §6.4 license caveat].
| 反模式 | 症状 | 修法 |
|---|---|---|
| Self-host for prestige at low volume | "We run our own AI" with usage far below V* | Run OP-1; below V* managed wins — pay $/token, not GPU+ops |
| Managed when compliance forbids it | Cheaper plan chosen, then legal/audit blocks it | Run OP-2 first — the gate overrides the slider |
| GPU-only costing | selfhost_cost = GPU price, ops assumed free | Add the ops_labor term (backups, monitoring, on-call, upgrades) to V* |
| "docker compose up = production" | No reverse proxy / HTTPS / backups / external DBs | OP-3: production = external Postgres/Redis/VectorDB + K8s + upgrade path [dify Case 3] |
| Ignoring per-replica ceilings | "Cheaper at scale" math never counts replicas | OP-4: replicas = peak_QPS / ~10 QPS-pod, re-feed into V* [dify §6.2] |
| Over-provisioning for peaks | Idle GPUs billed 24/7 for spiky traffic | OP-5 hybrid: self-host floor + managed burst; idle GPUs invert unit cost |
| Paying for same-image Enterprise tier | Buy Enterprise to "unlock" self-host capability | OP-6: tiers are the same image gated by env vars — buy *support* only if needed [dify Case 3] |
| One-way bet, no flip trigger | No abstraction; reversing = migration project | OP-7: thin OpenAI-compatible surface + documented bidirectional trigger |
| Treating the decision as permanent | Decided once in 2024, never revisited | OP-7: re-evaluate quarterly — volume and price/quality frontier both move |
V* is utilization-conditional. "Above V* → self-host" holds only at high, steady GPU utilization. Spiky traffic → hybrid (OP-5), not a fleet of idle GPUs.| Option | What you pay | Ops burden | Wins when | Examples |
|---|---|---|---|---|
| Managed API / cloud | $/token (marginal, no floor) | ~zero | below V*; no ops capacity; spiky/unpredictable volume; compliance satisfied by an in-region/BAA tier | OpenAI API, Anthropic API, AWS Bedrock, Dify Cloud |
| Self-host | GPU + ops labor + infra (fixed floor) + tiny marginal | high (DevOps, on-call, upgrades, backups) | above V* with high utilization and ops capacity; hard compliance/air-gap; vendor-neutrality required | vLLM + open weights ([[agentsop-llm-engine-selection]]); self-hosted Dify ([[agentsop-dify]]) |
| Hybrid | self-host floor + managed burst/tier | medium | high steady baseline plus spiky peaks, or premium/compliance tier + bulk tier | self-host baseline → burst to managed; compliance traffic self-host, bulk managed |
V* real) and caps over-provisioning.output/dify-sop-skill/SKILL.md — Case 3 (self-host vs cloud matrix, 实操要点), §6.2 (~10 QPS/pod), §6.4 (license caveat).output/vllm-sop-skill/SKILL.md — OP-4/OP-5 (throughput triage, prefix privacy), Dilemma 2 (tiered serving), Anti-pattern 6 (CPU provisioning), §7 (engine lock-in).[[agentsop-llm-engine-selection]] (which engine), [[agentsop-dify]] (how to build/operate self-hosted Dify).Create and train AI learning plugins with AgentDB's 9 reinforcement learning algorithms. Includes Decision Transformer, Q-Learning, SARSA, Actor-Critic, and more. Use when building self-learning agents, implementing RL, or optimizing agent behavior through experience.
Create and train AI learning plugins with AgentDB's 9 reinforcement learning algorithms. Includes Decision Transformer, Q-Learning, SARSA, Actor-Critic, and more. Use when building self-learning agents, implementing RL, or optimizing agent behavior through experience.
Design LLM applications using LangChain 1.x and LangGraph for agents, memory, and tool integration. Use when building LangChain applications, implementing AI agents, or creating complex LLM workflows.
Provide read-only NemoClaw maintainer policy. Use for questions about Issue Type, labels, Project fields, release labels, triage, duplicates, blocked items, and maintainer decisions. Trigger keywords - maintainer policy, workflow policy, project workflow, issue type, labels, label taxonomy, needs labels, project status, blocked issue, duplicate issue, daily release label, release train, triage policy.
Run stepped HTTP load tests with ab/wrk, ramping concurrency levels to collect p50/p90/p99 latency, detect performance inflection points, and recommend optimal concurrency. Triggered by requests like 'load test this URL', 'benchmark my API', 'find the max concurrency', or mentions of p99 latency, throughput saturation, or capacity planning.
Record episodes for an agentic env via teleoperation (keyboard, SO-ARM leader, or VR) into HDF5. Use when the user wants to teleop or record human demos.
| Investigate outliers, rare events, spikes, and suspicious records in datasets. Use as an explicit anomaly-analysis helper when you want concrete anomaly-detection workflow guidance, not generic data validation or end-to-end ML ownership.
Run any question, idea, or decision through a council of 5 AI advisors who independently analyze it, peer-review each other anonymously, and synthesize a final verdict. Based on Karpathy's LLM Council methodology. MANDATORY TRIGGERS: 'council this', 'run the council', 'war room this', 'pressure-test this', 'stress-test this', 'debate this'. STRONG TRIGGERS (use when combined with a real decision or tradeoff): 'should I X or Y', 'which option', 'what would you do', 'is this the right move', 'validate this', 'get multiple perspectives', 'I can't decide', 'I'm torn between'. Do NOT trigger on simple yes/no questions, factual lookups, or casual 'should I' without a meaningful tradeoff (e.g. 'should I use markdown' is not a council question). DO trigger when the user presents a genuine decision with stakes, multiple options, and context that suggests they want it pressure-tested from multiple angles.
Take agentsope/agentsop-selfhost-decision from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.