Apply systems engineering discipline to AI-powered products. Use when designing AI features for production, evaluating LLM integration points, choosing between AI and deterministic approaches, or architecting reliable AI-assisted workflows.
Can this be solved with rules/heuristics?
→ YES: Use deterministic logic. No AI needed.
→ NO: Is the task genuinely ambiguous?
→ YES: Use AI with validation + fallback.
→ NO: Reconsider the problem definition.
Request → Preprocessor (deterministic)
→ AI Worker (LLM call, isolated)
→ Validator (schema check)
→ Postprocessor (deterministic)
→ Output
type TextGenerator interface {
Generate(ctx context.Context, prompt string, opts Options) (string, error)
}
// Implementations: OpenAIGenerator, AnthropicGenerator, LocalModelGenerator
// Swap at config level, not code level
class AIBudget:
def __init__(self, max_tokens_per_request: int, max_cost_per_day: float):
self.max_tokens = max_tokens_per_request
self.max_daily_cost = max_cost_per_day
def check(self, estimated_tokens: int) -> bool:
return (estimated_tokens <= self.max_tokens
and self.daily_spend() < self.max_daily_cost)
Track per AI component:
- Accuracy (validated output vs expected)
- Latency (p50, p95, p99)
- Cost per call (tokens × rate)
- Fallback rate (how often AI is bypassed)
- Error rate (validation failures)