The Curriculum / Reader / Platform Engineering for AI
LEVEL 2 · INTERMEDIATE · COMPANY TRACK

Platform Engineering for AI

This page compiles 6 files from the repository, verbatim, in reading order. The living version: this folder on GitHub.

level-2-intermediate/company/01-platform-engineering/README.md

Platform Engineering for AI

Company AI should run on a shared platform, not dozens of hidden API keys and copy-pasted prompts. The platform owns model access, identity, routing, observability, configuration, budgets, and incident controls. Product teams own workflow behavior and evals.

Start small: one LLM gateway, one tracing convention, one secrets boundary, and one approved configuration path. Every request gets an organization, workflow, prompt version, model route, trace ID, cost record, and policy outcome. That is enough to compare workflows across teams without conflating data or spend.

The goal is not a grand internal platform. It is a paved road that makes the safe option the easy option: typed schemas, tenant-scoped tools, versioned prompts, auditable retrieval, and reversible rollouts.

In this module

Operating standard

Make this practice operational, not aspirational. Assign one directly responsible owner and name the decision they can make without another meeting. Put the key measure, threshold, and review cadence in the owning team's regular operating rhythm. A change to model, prompt, data scope, retrieval index, tool permission, or policy should be recorded with its expected impact and a rollback path. Preserve enough trace information to explain an individual bad outcome without exposing more customer or internal data than necessary. Review a small sample of real runs with the people doing the work; dashboards reveal trends, but operators reveal missing context. When the rule is violated, capture the incident, contain impact, add an eval or control, and update this document if the standard itself was unclear. The point is repeatable judgment under real workload, not a one-time compliance exercise.

level-2-intermediate/company/01-platform-engineering/llm-gateway-buildout.md

LLM Gateway Buildout

Put all provider calls behind a gateway. The gateway accepts a normalized request: authenticated actor, organization, workflow, model policy, messages or structured inputs, schema, budget, and trace context. It chooses an allowed provider/model, applies retries and timeouts, records tokens and cost, and returns a normalized response. Applications never hold broad provider credentials.

Use policies, not arbitrary model names. tenant_triage_classifier can use a fast approved model with a cost cap; lease_verifier can use a higher-accuracy model; sandbox experiments require an explicit flag. Enforce maximum context, output, requests, and concurrent calls. Support fallback only where schemas and evals prove compatibility.

The gateway must preserve provider response IDs, model version, cache status, latency, stop reason, and error class. Redact sensitive content in logs by default. Add per-workflow kill switches and organization budgets. Test provider outage, malformed schema, throttling, runaway retry, and model alias drift.

A gateway is where model choice becomes governable infrastructure instead of an application secret.

Operating standard

Make this practice operational, not aspirational. Assign one directly responsible owner and name the decision they can make without another meeting. Put the key measure, threshold, and review cadence in the owning team’s regular operating rhythm. A change to model, prompt, data scope, retrieval index, tool permission, or policy should be recorded with its expected impact and a rollback path. Preserve enough trace information to explain an individual bad outcome without exposing more tenant or deal data than necessary. Review a small sample of real runs with the people doing the work; dashboards reveal trends, but operators reveal missing context. When the rule is violated, capture the incident, contain impact, add an eval or control, and update this document if the standard itself was unclear. The point is repeatable judgment under real workload, not a one-time compliance exercise.

level-2-intermediate/company/01-platform-engineering/observability-stack.md

AI Observability Stack

Trace every agent run from user request through retrieval, tool calls, model calls, validation, human review, and final outcome. Use one trace ID and standard span names: ingest, retrieve, rerank, model, tool, validate, approve, send. Record versions, timing, token/cost data, policy decisions, and safe metadata.

Do not default to storing raw tenant messages, leases, or hidden reasoning. Store references, hashes, redacted excerpts, and access-controlled samples. Give operators a trace viewer that answers: what evidence was used, which tool was called, why was this escalated, what did it cost, and which version produced it?

Create dashboards for success rate, safety-gate rate, retrieval quality, schema failures, latency, cost per successful task, human overrides, and error classes. Alert on cross-tenant denials, emergency false negatives, cost spikes, retrieval freshness lag, and unusual tool enumeration. Observability without an owner and response playbook is a museum.

Operating standard

Make this practice operational, not aspirational. Assign one directly responsible owner and name the decision they can make without another meeting. Put the key measure, threshold, and review cadence in the owning team’s regular operating rhythm. A change to model, prompt, data scope, retrieval index, tool permission, or policy should be recorded with its expected impact and a rollback path. Preserve enough trace information to explain an individual bad outcome without exposing more tenant or deal data than necessary. Review a small sample of real runs with the people doing the work; dashboards reveal trends, but operators reveal missing context. When the rule is violated, capture the incident, contain impact, add an eval or control, and update this document if the standard itself was unclear. The point is repeatable judgment under real workload, not a one-time compliance exercise.

level-2-intermediate/company/01-platform-engineering/oncall-runbook.md

On-call runbook: when the AI stack breaks

Read this if: You are on call and an agent, RAG pipeline, or LLM gateway is misbehaving. You need the shortest path to "safe" — not a full incident write-up.

Stand-alone. You don't need the rest of this program to use it.

Severity, in one paragraph

If you're reading this at 2 AM, the question is: is anything reaching external humans or systems right now? If yes, SEV-1.

SEV-1: kill first, investigate second

  1. Flip the kill switch. Every production agent must have one. If you don't know where it is, that's your first bug and it's serious.
  2. Prefer a config flag (enabled: false) over deleting the deployment. You want to preserve state for post-mortem.
  3. If the flag doesn't exist, revoke the agent's credentials at the source (IAM, API keys). Slower to recover, but effective.
  4. Announce. Post in your incident channel: what agent, what symptom, what you just did.
  5. Freeze inputs. If the agent is fed by a queue or webhook, pause the source too. You don't want a backlog to replay through a fixed agent that hasn't earned trust yet.
  6. Snapshot state. Grab the last 100 traces, the current config, the eval history. Store in the incident folder before anything gets rotated.
  7. Assign an owner if you're not it. The named owner of the agent is on point. If they're unreachable, their manager is.

SEV-2: contain, don't kill

The agent is drafting, not acting. You have time.

  1. Flip auto-send to false on every tool the agent has, if it isn't already.
  2. Increase the sampling rate on the human review — every draft gets reviewed, not one in ten.
  3. Enable verbose logging so you can see what changed.
  4. Do not roll back yet. You don't know what to roll back to. Diagnose first.

The diagnostic checklist

Work through these in order. Stop at the first one that explains the symptom.

  1. Did anything deploy in the last 24 hours? Model, prompt, retrieval index, tool permissions, config. Check the change log. Rollback beats debug.
  2. Is the underlying model behaving? Hit the model directly (no agent, no RAG) with a known-good prompt. If the raw model is bad, you have an upstream problem — check provider status page.
  3. Is retrieval returning garbage? Log the top-K chunks for a failing query. If the chunks are irrelevant, the index is stale, poisoned, or the embedding model changed. See ../03-rag-at-scale/refresh-orchestration.md.
  4. Did the tool interface change? External APIs the agent calls sometimes silently change response shape. Check the tool call logs for HTTP 200 with unexpected payload shape.
  5. Is a specific user or tenant triggering it? Filter traces by user_id. If it's one tenant, you have a data problem in their scope — see ../03-rag-at-scale/multi-tenant-rag.md.
  6. Is it prompt injection? If the failing inputs contain instructions targeting the agent ("ignore previous instructions", "forget your rules"), you're being attacked. Escalate to security.
  7. Cost spike? If the symptom is bill, not behavior, check for infinite tool-use loops. See ../06-cost-management/spend-alerting.md.

The rollback rules

You may roll back without a full post-mortem when:

You must not roll back without a plan when:

If any of those apply, treat the current state as the new baseline and fix forward. Add "roll forward is now the only option" to the incident record.

The 24-hour post-incident checklist

What this doc explicitly does not cover

Related

level-2-intermediate/company/01-platform-engineering/secrets-and-config.md

Secrets and Configuration

Keep secrets in a managed secret store, injected at runtime with least privilege and rotation support. Never place provider keys, Supabase service keys, webhook secrets, or tenant credentials in prompts, client bundles, logs, eval fixtures, or source control. Give each environment separate credentials and make production writes impossible from local development by default.

Configuration is different from secrets. Store model routes, prompt versions, thresholds, feature flags, budgets, and tool allowlists in versioned, reviewed configuration. Validate config schemas at deploy time. Every request should record the effective config version so behavior can be reproduced.

Scope keys by service and purpose. An ingestion worker should not be able to send tenant messages; an MCP read server should not have service-role write authority. Rotate after exposure, revoke on offboarding, and audit secret access. Use canary credentials to detect accidental disclosure.

The operational test is simple: if a trace, screenshot, or support export leaks, does it expose something an attacker can use? Design for no.

Operating standard

Make this practice operational, not aspirational. Assign one directly responsible owner and name the decision they can make without another meeting. Put the key measure, threshold, and review cadence in the owning team’s regular operating rhythm. A change to model, prompt, data scope, retrieval index, tool permission, or policy should be recorded with its expected impact and a rollback path. Preserve enough trace information to explain an individual bad outcome without exposing more tenant or deal data than necessary. Review a small sample of real runs with the people doing the work; dashboards reveal trends, but operators reveal missing context. When the rule is violated, capture the incident, contain impact, add an eval or control, and update this document if the standard itself was unclear. The point is repeatable judgment under real workload, not a one-time compliance exercise.

level-2-intermediate/company/01-platform-engineering/sso-and-access.md

SSO and access: who can use, deploy, and stop your agents

Read this if: You are about to give the third engineer on your team access to a production agent, or the AI vendor you signed up for is asking about SAML, or you can't answer "which employees can talk to our RAG?" in under 30 seconds.

Stand-alone. No prerequisites in this program.

The three access questions every AI system has to answer

  1. Who can use it? (Runtime access — sending prompts, calling tools)
  2. Who can change it? (Build access — modifying prompts, tools, retrieval indexes, model choice)
  3. Who can stop it? (Kill switch access — pausing, disabling, or retiring the agent)

If those three groups are the same group, you have a governance problem. If any of them is "everyone," you have a bigger one.

The minimum bar for any production agent

An agent with hardcoded API keys or shared logins is not production-ready. It's a demo.

Recommended group layout

Copy this into your identity provider. Adjust naming to your org's conventions.

Group Purpose Typical members
ai-users-<agent-name> Runtime access — send prompts, receive drafts End users of that specific agent
ai-reviewers-<agent-name> Review drafts before send (Category 2 approval) People with the authority to send on the company's behalf
ai-owners-<agent-name> Build access — deploy, change config The named owner and their delegates
ai-admins Cross-cutting kill switch, cost caps, credential rotation Platform team, security team
ai-auditors Read-only access to traces, logs, eval history Compliance, legal, third-party auditors

Every agent gets its own ai-users- and ai-reviewers- group. Owners groups can be shared across small related agents. Admins and auditors are org-wide.

Vendor-side SSO checklist

Every AI vendor you use should support the below. If they don't, know what you're accepting.

If your vendor doesn't support SCIM, you need a manual quarterly access review, and you should assume someone will keep access longer than they should.

Service accounts and API keys: the actual dangerous surface

SSO covers humans. Service accounts and API keys are where breaches happen. Rules:

  1. One key per agent per environment. Not "the shared prod key."
  2. Named owner on every key. Rotate when they leave.
  3. Short-lived where possible. OAuth client credentials with 1-hour token expiry beats a static bearer token.
  4. Scoped, not root. The agent's key can access exactly the tools it needs, nothing else.
  5. Stored in a secrets manager. Never in git, never in .env files committed to shared drives, never in Slack.
  6. Rotated on a schedule — quarterly minimum, immediately on any incident, immediately on team departure.

If you have keys older than a year and haven't rotated because "it might break something," you already know it will break at the worst possible time. Rotate now during business hours.

Multi-tenant SaaS twist

If your AI system serves multiple customers, add:

Deprovisioning: the drill nobody runs

Run this quarterly. It's the drill that finds the actual gaps.

  1. Pick a "recently departed" employee (real or simulated).
  2. Time yourself: how long until every one of their accesses is gone?
  3. SSO group removal (should be automatic on employment termination)
  4. API keys under their name (rotated or revoked)
  5. Anything they built as owner (transferred to a new owner)
  6. Kill-switch reachability confirmed after their removal
  7. If any step took more than one business day, you have a gap. Fix it before the next drill.

What good looks like

You can answer these four questions from your desk in under five minutes:

If any of those takes more than five minutes, you have work to do.

Related

← Combine Two Agents: Lease Portfolio Diligence Agent Governance →