Skip to content

Commit a727ecb

Browse files
authored
docs: clarify 12-factor config principle for hierarchical AI agent architectures (#1395)
Closes #1393 Add caveat section explaining that 12-Factor's "Config in Environment" principle needs reinterpretation for AI agent systems. While the directional principle (separate code from config) still holds, the mechanics differ from stateless web apps: - Web apps: Simple key-value env vars work - AI agents: Hierarchical YAML/JSON needed for behavioral policies The caveat clarifies: - Schema enforcement and namespacing requirements - Complex data types (lists, objects, references) - Visibility/reproducibility through version-controlled configs - Why literal env vars quickly become unmaintainable for agent configs Configuration still lives in "the environment" - it's just that "environment" means structured config files, not literal shell variables.
1 parent 78920d6 commit a727ecb

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

knowledge/principles/config-in-environment.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,43 @@ Configuration that varies between users (paths, preferences, workflows) should b
88

99
**In AI agents:** Users declare **what** they want (config), agents implement **how** to achieve it (code).
1010

11+
## Caveat: Beyond 12-Factor's Assumptions
12+
13+
**The 12-Factor principle was written for stateless web apps.** It assumes configuration is simple key-value pairs (ports, credentials, feature flags) that fit naturally into environment variables.
14+
15+
**AI agent architectures need richer, hierarchical configs** that describe behavioral policy, not just deployment settings. This means:
16+
17+
- **Schema enforcement and namespacing** - Not just `API_KEY=xyz`, but nested structures like `agents.extract-best-frame.selection_criteria.optimize_for`
18+
- **Complex data types** - Lists, objects, and references between config sections (e.g., `${user.persona.description}`)
19+
- **Visibility and reproducibility** - Which config influenced which run? Version-controlled YAML provides an audit trail that scattered env vars don't
20+
21+
**Literal interpretation breaks down:**
22+
```bash
23+
# ❌ Literal 12-Factor (env vars only)
24+
EXTRACT_BEST_FRAME_OPTIMIZE_FOR="professional"
25+
EXTRACT_BEST_FRAME_TARGET_PERSON="6'3\", hazel eyes"
26+
EXTRACT_BEST_FRAME_FACTORS_1="facial_expression"
27+
EXTRACT_BEST_FRAME_FACTORS_2="eye_engagement"
28+
# ...quickly becomes unmaintainable
29+
30+
# ✅ Directional 12-Factor (structured config)
31+
agents:
32+
extract-best-frame:
33+
selection_criteria:
34+
optimize_for: "professional"
35+
target_person: "${user.persona.description}"
36+
factors: ["facial_expression", "eye_engagement"]
37+
```
38+
39+
**The directional principle still holds:** Separate configuration from code. But the mechanics differ:
40+
41+
- **Web apps:** Flat env vars work because configs are simple
42+
- **AI agents:** YAML/JSON/databases work because configs are hierarchical behavioral policies
43+
44+
**Configuration still lives in "the environment"** - it's just that "environment" means version-controlled YAML files loaded at runtime, not literal shell environment variables.
45+
46+
Don't treat 12-Factor as literal law. Treat it as directional guidance - **separation of code and config** - and reinterpret the mechanics for your agentic, composable world.
47+
1148
## The Problem
1249

1350
Hard-coded config blocks shareability:

0 commit comments

Comments
 (0)