agent-system-design

v2026.09.24

Production agent SLA discipline — MAX_LOOPS, MAX_TOKENS, MAX_COST, MAX_LATENCY, MAX_TOOL_CALLS, circuit breakers, sovereignty boundaries, degradation modes. Use before deploying any autonomous loop to production.

GitHub
安装命令
npx skhub add akillness/agent-system-design
Markdown
SKILL.md

Agent System Design

Overview

Demos run forever; production cannot. This skill defines the five budgets every production agent must enforce, the circuit breakers that stop runaway loops, and the sovereignty rules that keep agents from straying outside their domain.

When to use

  • Moving an agent from prototype to production
  • An agent looped, spent $200, and produced nothing useful
  • You can't answer "what is this agent allowed to do?" in one sentence
  • Need to set SLO/SLA with stakeholders
  • Multi-agent system where one agent can call another

The five budgets

BudgetDefault capWhen exceeded
MAX_LOOPS25 iterationsStop, hand to human
MAX_TOKENS200k per runSummarize state, restart
MAX_COST_USD$2 per runHard stop, page operator
MAX_LATENCY_S300s wall clockReturn partial, log incomplete
MAX_TOOL_CALLS50 per runStop, suspicious behavior

Caps are per run, enforced by the harness, not by prompting the LLM.

Loop termination rules

Stop when ANY of these is true:

  1. Goal verified (tests pass / acceptance criteria met)
  2. Budget cap hit
  3. Same tool+args repeated 3× → loop detector
  4. Guardrail block (see agent-guardrails)
  5. HITL approval denied
  6. Operator kill signal

Circuit breaker pattern

class AgentCircuitBreaker:
    def __init__(self, max_failures=3, window_s=60, cooldown_s=300):
        self.failures = deque()
        self.tripped_until = 0

    def call(self, fn, *args):
        now = time.time()
        if now < self.tripped_until:
            raise CircuitOpen()
        try:
            return fn(*args)
        except Exception:
            self.failures.append(now)
            self._prune(now)
            if len(self.failures) >= self.max_failures:
                self.tripped_until = now + self.cooldown_s
            raise

Apply per tool, per downstream service, per agent.

Sovereignty boundaries

Every agent has a domain card:

agent: billing-assistant
owns:
  - invoice CRUD
  - refund initiation (HITL required > $100)
borrows:
  - customer lookup (read-only, via customer-agent)
forbidden:
  - user account deletion
  - sending external emails
escalates_to: ops-on-call

Rule: an agent never silently calls outside its owns set. Cross-domain calls go through explicit routing (see a2a-protocol).

Degradation modes

When upstream fails, degrade rather than crash:

FailureDegradation
LLM API downCached answer + "stale" flag
Tool service downSkip optional tools, mark partial
Budget hit mid-runSummarize progress, queue resume
Guardrail uncertainDefault-deny + HITL

Retry policy

  • Exponential backoff with jitter, max 3 attempts
  • Idempotency keys on all state-changing tools (see mcp-builder)
  • Never retry guardrail blocks (they're decisions, not failures)

Reference dataclass

@dataclass
class AgentSLA:
    max_loops: int = 25
    max_tokens: int = 200_000
    max_cost_usd: float = 2.0
    max_latency_s: int = 300
    max_tool_calls: int = 50
    require_hitl_above_usd: float = 100.0
    circuit_breaker: AgentCircuitBreaker = field(default_factory=AgentCircuitBreaker)
    on_cap_hit: Literal["stop", "summarize_restart", "escalate"] = "stop"

Further reading

  • SRE for agents — SLO, error budget, postmortems
  • Circuit breaker patterns (Hystrix, resilience4j)
  • LLM cost-control playbooks (2026)
  • Pair with: agent-guardrails, agent-observability
发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.24

发布时间

Sep 24, 2026

分类

未分类

许可证

未指定

源路径

.agent-skills/agent-system-design

默认分支

main

最新提交

f579bfe

Tree SHA

34a09b3