Skip to main content
Before deploying to production, your release gate agent collects evidence, summarizes risk via an LLM tool call, and may trigger a CI/CD pipeline. This recipe models that as a pipeline session with explicit high-risk metadata. Source: production-release-gate-loop.ts · production_release_gate_loop.py

Scenario

A release gate orchestrator validates rollout readiness. It calls an LLM tool to summarize risk, then triggers a CI/CD pipeline via MCP. Both actions need production metadata for guardrails.

Step 1 — Pipeline session

await apie.withSession(
  {
    kind: "pipeline",
    inputSummary: "Validate production rollout readiness",
    metadata: { workflow: "release_gate" },
  },
  async (session) => { /* orchestrator run inside */ },
);

Step 2 — Orchestrator run with step metadata

await apie.withRun(
  {
    sessionId: session.id,
    stepKey: "orchestrator",
    stepName: "Release gate orchestrator",
    stepIndex: 0,
    inputSummary: "Collect rollout evidence and risky actions",
  },
  async (run) => { /* tool calls inside */ },
);

Step 3 — LLM tool call (medium risk)

await withOpenAIToolCall(apie, {
  runId: run.id,
  toolName: "summarize_release_risk",
  arguments: { service: "api", environment: "production" },
  resourceType: "work_item",
  riskLevel: "medium",
}, async () => ({ summary: "No blocker found in latest incident feed." }));

Step 4 — MCP CI/CD trigger (high risk)

await withMcpToolCall(apie, {
  runId: run.id,
  sessionId: session.id,
  server: "internal-cicd",
  tool: "trigger_pipeline",
  actionType: "execute",
  resourceType: "pipeline_run",
  environment: "production",
  riskLevel: "high",
  resourceTarget: "payments-service",
}, async () => ({ accepted: true, runId: "pipe_123" }));

What you’ll see

A pipeline session replay with orchestrator run, LLM tool call (medium risk), and MCP pipeline trigger (high risk). In Monitor mode, guard evaluations show what would be blocked in Enforce mode.

Escalate to enforcement

  1. Declare capabilities for trigger_pipeline and summarize_release_risk
  2. Enable guardrail templates for prod-deploys
  3. Switch to Enforce mode

Next steps

Multi-agent handoff

Orchestrator delegates to worker.

MCP instrumented client

In-process MCP setup.