Skip to main content

Architecture & Components

k8s-autopilot is built on the production-grade Deep Agent pattern — a multi-tier hierarchy of agents, MCP servers, and HITL gates. This page covers the architectural components that power the system. For domain-specific capabilities, see the Capabilities pages.


1. 🎯 Supervisor Agent

The Supervisor Agent is a pure router that delegates ALL Kubernetes infrastructure requests to the appropriate domain coordinator. It never performs operations directly.

Routing Table

Request TypeToolTarget Coordinator
Helm chart generation/update/opstransfer_to_helm_operatorHelm Operator Coordinator
K8s cluster ops (pods, scaling, exec)transfer_to_k8s_operatorK8s Operator Coordinator
ArgoCD / Argo Rollouts / Traefiktransfer_to_app_operatorApp Operator Coordinator
Prometheus / Alertmanager / OTel / Loki / Tempotransfer_to_observability_operatorObservability Coordinator
Clarification / out-of-scoperequest_human_feedbackUser

Natural Language Mapping

The Supervisor translates non-technical language into domain-aware routing:

User SaysMaps ToCoordinator
"deploy", "ship", "release"ArgoCD syncApp Operator
"zero downtime", "gradual"Argo Rollouts canary/blue-greenApp Operator
"split traffic", "A/B test"Traefik weighted routingApp Operator
"scale up", "more capacity"K8s scalingK8s Operator
"what's firing", "on-call"Alert triageObservability
"silence", "mute"Create silenceObservability
"metrics", "PromQL", "CPU spikes"Prometheus queryObservability
"trace", "latency", "bottleneck"Tempo distributed tracingObservability
"logs", "error patterns", "LogQL"Loki log aggregationObservability
"instrument service", "collector"OpenTelemetry pipelinesObservability

Context Engineering

The Supervisor uses a 3-layer middleware stack to maintain routing accuracy across long sessions:

MiddlewarePurpose
SupervisorContextMiddlewareRe-injects accumulated domain summaries as a SystemMessage before every model call — ensures cross-domain awareness survives summarization
SummarizationMiddlewareAuto-compresses conversation history when it exceeds ~75% of context budget (default: 4000 tokens), keeping only the last 6 messages
ModelCallLimitMiddlewareCaps model calls at 15 per turn to prevent runaway routing loops

2. 🧩 Domain Coordinators

Each coordinator is a Deep Agent — a LangGraph-based orchestrator that manages its own team of sub-agents. Coordinators handle:

  • Intent extraction: Translating user requests into DevOps-aware parameters
  • Sub-agent delegation: Routing to the correct sub-agent with [PLAN-LOCKED] context
  • HITL orchestration: Presenting plans and collecting approval before delegating execution
  • Operations journaling: Logging every operation for context persistence
CoordinatorSub-AgentsCapabilities Page
helm-operator-coordinator7 (planner, skill-builder, generator, validator, updater, operation, github)Helm Operator
app-operator-coordinator3 (argocd-onboarder, argo-rollouts-onboarder, traefik-edge-router)App Operator
k8s-operator-coordinator1 (k8s-cluster-ops)K8s Operator
observability-coordinator5 (prometheus-operator, alertmanager-operator, opentelemetry-operator, loki-operator, tempo-operator)Observability

3. 🔌 JIT MCP Connections

Sub-agents that interact with external systems use a Just-In-Time (JIT) connection pattern. Instead of holding open connections to all 10 MCP servers for the entire session, each sub-agent is wrapped in a CompiledSubAgent that only opens its MCP connection when that specific node is executed. The connection is closed immediately after the sub-agent completes.

Connection Types

TypeDescriptionUsed By
JIT MCPOpens MCP connection lazily, closes after executionAll MCP-connected sub-agents
Static DictSimple dict spec, no MCP — uses filesystem and in-memory toolshelm-skill-builder, helm-generator, helm-updater, helm-validator
Compiled SubgraphLangGraph subgraph with its own internal supervisorhelm-planner

4. 🛡️ Human-in-the-Loop Governance

AI shouldn't arbitrarily execute state-modifying operations on your cluster. k8s-autopilot enforces strict HITL governance at multiple layers.

The [PLAN-LOCKED] Delegation Protocol

Every state-modifying operation follows a mandatory Intent → Plan → Approve → Execute lifecycle:

  1. Intent Extraction: The coordinator translates the user's request into DevOps-aware parameters
  2. Plan Presentation: A structured plan is presented via request_user_input with action details, resource names, namespaces, and impact assessment
  3. User Approval: The LangGraph execution pauses (interrupt()) and the UI renders an approval card
  4. [PLAN-LOCKED] Execution: After approval, the coordinator delegates to the sub-agent with the [PLAN-LOCKED] prefix — the sub-agent skips its own planning phase and executes pre-approved parameters directly
  5. Verification: The sub-agent confirms the operation's success independently

Operation Classification

Operation TypeApproval RequiredExample
Read-OnlyNo — instant execution"List pods", "check sync status", "query metrics", "TraceQL lookup"
State-ModifyingYes — full HITL pipeline"Deploy app", "scale deployment", "create silence", "install exporter"
Commit GatesYes — explicit confirmation"Push chart to GitHub", "sync ArgoCD app"

Rejection Protocol

If a user rejects a plan:

  • The agent does not retry autonomously with modified parameters
  • It asks the user what to adjust
  • Maximum of 2 plan presentations per request before asking the user to rephrase

5. ⚡ Advanced Middleware Stack

k8s-autopilot implements a dedicated middleware stack to protect cluster stability and prevent LLM context degradation:

A2UI Buffer Interceptor (A2UIBufferMiddleware)

Complex observability queries (e.g. distributed trace trees, 500-line log streams, PromQL range matrices) return megabytes of raw JSON that can exhaust the LLM's context window.

The A2UIBufferMiddleware intercepts raw data from MCP tools, stores it in the LangChain tool artifact store, and provides the LLM with a lightweight pointer string. The sub-agent then calls build_obs_a2ui to stream interactive charts, timelines, and log tables directly to the UI via the A2UI Protocol without loading payload bytes into the prompt.

Operations Context Injection (ObsOperationContextMiddleware)

Survives standard LangGraph message summarization by actively prepending the recent operations log as a SystemMessage just-in-time before each model invocation.

Code Interpreter Middleware (PTC Allowlist)

Sub-agents are equipped with Python Tool Calling (PTC) within a sandbox. Instead of issuing dozens of sequential tool calls to inspect individual pods or targets, sub-agents can run a programmatic loop to query read-only endpoints and aggregate results in a single step.


6. 🔄 Cross-Domain Handoff Protocol

When a coordinator determines that a user's request belongs to a different domain, it emits a structured signal:

"This is outside my scope. Please use the appropriate operator.
User Request: [The user's specific request]
Context: [What was previously discovered]"

The Supervisor detects this via pattern matching, extracts the structured context, and immediately re-routes to the correct coordinator with a [CROSS-DOMAIN] prefix — injecting the prior coordinator's findings:

[CROSS-DOMAIN] Source: observability. 
Prior findings: 5 critical alerts for checkout service.
User Request: Check pod status for checkout service

This "blackboard pattern" enables seamless multi-domain investigations without the user repeating themselves.


7. 🧠 Skills, Memory & Context Engineering

k8s-autopilot maintains persistence and context awareness using a multi-layered virtual filesystem backed by a CompositeBackend:

Virtual PathBackendPurpose
/skills/StateBackend (LangGraph state)Operational workflow instructions loaded by sub-agents
/memories/StoreBackend (InMemoryStore, org-scoped)Governance files and operations journals
/workspace/FilesystemBackend (real disk)Generated chart files, synced via sync_workspace_to_disk
/shared/StoreBackend (shared namespace)Cross-domain shared context

Skills

Skills are strict operational playbooks that dictate exactly how each sub-agent must interact with MCP servers. Each skill directory contains:

  • SKILL.md — YAML frontmatter + step-by-step workflow
  • references/ — Domain-specific patterns and templates
DomainSkill DirectoriesSub-Agents
Helm6 directories (generator, skill-builder, operation, validator, updater, github-agent)7 sub-agents
App3 directories (argocd-gitops, argo-rollouts-gitops, traefik-edge-routing)3 sub-agents
K8s1 directory (kubernetes-cluster-ops)1 sub-agent
Observability5 directories (prometheus, alertmanager, opentelemetry, loki, tempo)5 sub-agents

8. ⚙️ State Management

Each agent operates on its own dedicated state schema, optimized for its specific task:

State SchemaUsed ByKey Fields
MainSupervisorStateSupervisoruser_query, workflow_state, active_phase, domain_summaries, cross_domain_context
Coordinator StatesEach coordinatormessages, user_query, domain-specific fields
Sub-Agent StatesEach sub-agentInherited from coordinator via input_transform

State Transformers

Data is not shared blindly. A StateTransformer middleware explicitly converts data when moving between the Supervisor and coordinators. This ensures context isolation — sub-agents see only what they need, preventing hallucination from irrelevant history.


9. 🛠 Tech Stack & MCP Servers

ComponentTechnologyPurpose
Agent Frameworkdeepagents / LangGraphState machine, orchestration, sub-graph routing
LLM InterfaceLangChain CoreTool execution, message schemas
Tools/IntegrationsModel Context Protocol (MCP)Standardized protocol for external systems
User InterfaceA2UI / TalkOps A2AReal-time streaming, HITL approval cards, markdown rendering
PersistencePostgreSQL (AsyncPg / Psycopg)Durable state machine checkpointing across sessions
RuntimePython 3.12+Core agent backend

MCP Servers

k8s-autopilot connects to 10 MCP servers — TalkOps-native servers (PyPI packages, stdio transport) and external tools:

MCP ServerPackage / CommandTransportDomain
helm_mcp_serverhelm-mcp-serverstdioHelm chart operations & releases
argocd_mcp_serverargocd-mcp-serverstdioArgoCD GitOps sync & app projects
traefik_mcp_servertraefik-mcp-serverstdioTraefik IngressRoutes & middlewares
argo_rollout_mcp_serverargo-rollout-mcp-serverstdioProgressive delivery canary & blue-green
prometheus-mcp-serverprometheus-mcp-serverstdioPrometheus metrics & PromQL
alertmanager-mcp-serveralertmanager-mcp-serverstdioAlertmanager triage & silences
opentelemetry-mcp-serveropentelemetry-mcp-serverstdioOTel Collector & auto-instrumentation
loki-mcp-serverloki-mcp-serverstdioLoki log aggregation & LogQL
tempo-mcp-servertempo-mcp-serverstdioTempo distributed tracing & TraceQL
kubernetes_mcp_servernpx kubernetes-mcp-server@lateststdioRaw Kubernetes cluster ops