C-13 Resource Limits
Brick C: Agents, autonomy, execution. French version: C-13-resource-limits
1. Role and responsibilities
Bounds consumption per run, agent and tenant: Kubernetes quotas (CPU, memory) and runtime limits (steps, tokens, cost, duration, concurrency).
- Reserve a quota before the run (brick H quotas)
- Apply ResourceQuota / LimitRange
- Limit concurrent runs per agent
2. Position in the architecture and interactions
- Callers: Agent Runtime, Sandbox, FinOps.
- Execution path: Synchronous at start, continuous check in the loop.
- Every interaction goes through the Control Plane API v1 (
/v1) behind the API Gateway (D-14).
3. Open source component and developed part
- Open source: Kubernetes ResourceQuota, LimitRange
- Developed: Runtime limits and quota reservation.
- External integration through an adapter
eai/integrations/<system>.pywith an in-process fallback when the URL is not configured.
4. Data model
Tables (schema eai, tenant_id RLS):
eai.runs(budgets)eai.quotas
Common columns: id uuid, tenant_id uuid NOT NULL, created_at, updated_at; RLS policy current_setting('app.tenant_id', true)::uuid.
5. Contract
- Applied contract: agent-manifest + execution-contract
- JSON Schema:
contracts/v1/agent-manifest.schema.json,contracts/v1/execution-contract.schema.json - Key fields:
spec.budgets, budgets.max_cost, budgets.max_duration_s - Validation:
POST /v1/contracts/{name}/validate; manifest apply:POST /v1/manifests/apply.
6. API endpoints
POST /v1/quotas/reservePOST /v1/agents/{id}/runsPATCH /v1/agents/{id}
Request PATCH /v1/agents/{id}:
{
"budgets": {
"max_steps": 30,
"max_concurrent_runs": 5,
"max_cost": {
"amount": "2.00",
"currency": "EUR"
}
}
}
Response:
{
"id": "agt_support",
"version": 4,
"budgets": {
"max_steps": 30,
"max_concurrent_runs": 5
}
}
7. SDK examples
Python:
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
client.agents.run("agt_support", "Triage the open tickets", budgets={"max_tool_calls": 30})
TypeScript:
import { EnterpriseAI } from "@enterprise-ai/sdk";
const client = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
await client.agents.run("agt_support", { task: { objective: "Triage INC-42" }, budgets: { max_steps: 30 } });
Java:
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
client.runs().start("agt_support", Map.of("task", "Summarize INC-42", "budgets", Map.of("max_steps", 30)));
Go:
c, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
c.Runs.Start(ctx, "agt_support", map[string]any{"task": "Summarize INC-42", "budgets": map[string]any{"max_steps": 30}})
8. Configuration
- Environment variables:
EAI_DATABASE_URL - Helm values keys:
controlPlane.resources,sandbox.runtimeClasses
9. Security controls
- Limits cannot be changed by the agent itself
- Every request carries the tenant resolved from the credential; PostgreSQL RLS
- Every mutation and policy decision writes a hash-chained audit event
10. Observability
- Prometheus metrics:
eai_budget_exceeded_total{kind},eai_runs_concurrent - Traces: OpenTelemetry spans with GenAI semantic conventions (
gen_ai.operation.name,gen_ai.agent.id,gen_ai.tool.name), attributeseai.tenant_id,eai.run_id,traceparentpropagation. - Audit actions:
run.transition
11. FinOps units
- Quota reservation then commit / release.
- Emitted as Usage Event (
POST /v1/finops/usage) with tenant, project, agent and run.
12. Failure modes and resilience
- Quota unavailable -> 429 quota_exceeded
- Automatic release at run end
- Normalized errors (error envelope, message_i18n en/fr)
13. Standalone adoption (client of a client)
- enterprise_ai.agent + enterprise_ai.quotas.
- SDK:
enterprise_ai.agent(AgentsClient,RunsClient,SessionsClient) - Minimal deployment: Helm chart with
controlPlane.enabled=trueand PostgreSQL; disabled external components use their in-process fallback.
14. Acceptance tests
- 6th concurrent run with limit 5 -> 429
- Cross-tenant access refused
- Error returned in fr with Accept-Language: fr