Architecture overview

The browser reaches platform-api. That API owns tenant authorization and platform workflows; kagent’s scheduler starts every run, and kagent and Substrate run the sessions; agentgateway handles model traffic; Lago invoices usage and Stripe collects payment.

Browser → GKE Gateway → platform-api
  ├─ Kubernetes: Agent + AgentTemplate + Harness, BrokerAccount
  ├─ kagent APIs: schedules (ScheduledRunService), sessions, tasks and live A2A observations
  ├─ Firestore: tenants, billing state, usage evidence and delivery watermarks
  ├─ Lago: usage events, the monthly plan and invoices
  └─ Stripe: payment methods and payment standing; Lago charges invoices through it

Session → tenant Substrate WorkerPool → pinned kagent runtime
  └─ agentgateway
       ├─ → Vertex AI
       ├─ → platform MCP → scheduling
       ├─ → broker MCP → paper trading
       └─ → data MCP → public data

Runtime and tenancy boundaries

Firebase identity is resolved to a tenant by platform-api. Browser clients do not choose their Kubernetes namespace or connect directly to kagent’s control plane. Admin operations add a server-side allowlist check. See Tenant isolation.

Agents are headless, and the browser only reads their runs. Every run starts from a schedule: one set at creation comes due, a wake the agent booked comes due, or its owner chooses Run now. platform-api writes every schedule to kagent 1.0’s ScheduledRunService as the tenant’s owner, and kagent’s controller fires it, opening a fresh session for each run and sending the schedule’s prompt over A2A. Run now is kagent’s TriggerScheduledRun, which platform-api refuses to call while a run of the agent is still going (kagent has no such rule). platform-api’s calls go through agentgateway’s kagent listener, whose authorization admits only SessionService, ScheduledRunService and A2A. See Streaming.

The pinned kagent 1.0.1 integration uses api.kagent.dev/v1alpha3 Agent, AgentTemplate and Harness resources. The Harness references a tenant WorkerPool and snapshot location. Sessions and tasks are reached through kagent’s APIs; there are no platform Session or Task CRDs. See The agent runtime for the version boundary with current upstream docs.

Substrate supplies session execution and suspend/resume. The custom runtime has baked Git-package skills and file tools; native Bash and ask_user are off through kagent’s config.runtimeDefaults.builtinTools Helm values. The platform MCP endpoint supplies the agent’s own wakes, behind agentgateway like every other tool server. See Runtime isolation.

State and evidence

Concern Owner
Agent definitions and runtime configuration Kubernetes resources reconciled by the stock kagent and Substrate controllers at their pinned chart versions
Schedules and their executions kagent’s database, through ScheduledRunService
Brokerage account ownership Platform custom resources and reconcilers
Session/task projections and execution state kagent/Substrate APIs and their persistence
Tenants, notifications, payment state and usage delivery evidence Firestore through platform-api
Usage rating and monthly invoices Lago, self-hosted in the lago namespace
Payment collection Stripe, charged by Lago
Leaderboard ordering Redis index with platform-owned source records
Traces and metrics OpenTelemetry collectors, Cloud Trace and Cloud Monitoring

Live output, durable usage evidence and customer-rated charges are different records. The streaming and billing contracts state their coverage and reconciliation limits. Compute running seconds are derived from Substrate’s actor lifecycle records, routed through Cloud Logging and Pub/Sub into platform-api, which folds them into running intervals and ledger rows. Dashboard resource capacity is not a substitute for that measurement.

Infrastructure dependencies

Terraform owns shared infrastructure, not each tenant’s agent. The tracked CI dependency graph makes gcp/platform a producer for both github and gcp/workloads; changes select downstream consumers and execute producers first. Workloads providers need a real cluster even during a plan. The separate stripe root manages native collection configuration, not usage meters.

The deploy pin file binds both platform and runtime image digests and the baked skills commit. See The deploy path for promotion and verification boundaries.

Observability

The gateway exports access telemetry used by the inference ledger and publishes scrape metrics. Substrate’s actor lifecycle log stream, in its stdout and OTLP copies, is the compute meter’s evidence, so it is routed and never sampled. The collectors also observe controller/runtime health; these metrics do not replace usage evidence. Delegation graphs are reconstructed from configured trace reads and may be unavailable or incomplete. Request content is not required for usage attribution, so logging policy should keep prompt and completion content out of the gateway usage stream.