|
1 | 1 | # AGENTS.md |
2 | 2 |
|
3 | | -Instructions for AI agents and automation tools using the Extropy CLI. |
| 3 | +Operational guide for AI agents and automation tools using the Extropy CLI. |
4 | 4 |
|
5 | | -## Agent Mode |
| 5 | +## Automation Mode |
6 | 6 |
|
7 | | -Set agent mode for structured JSON output and non-interactive operation: |
| 7 | +Use agent mode for machine-readable output and non-interactive behavior: |
8 | 8 |
|
9 | 9 | ```bash |
10 | 10 | extropy config set cli.mode agent |
11 | 11 | ``` |
12 | 12 |
|
13 | | -Or use the `--json` flag per-command: |
14 | | - |
15 | | -```bash |
16 | | -extropy results --json |
17 | | -extropy query summary --json |
18 | | -``` |
19 | | - |
20 | | -**Agent mode behavior:** |
21 | | - |
22 | | -- All output is JSON (parseable, no ANSI formatting) |
23 | | -- Exit codes indicate success/failure (0 = success, non-zero = error) |
24 | | -- No interactive prompts — commands fail fast if missing required input |
25 | | -- Clarification requests return exit code 2 with structured error |
| 13 | +Agent mode behavior: |
| 14 | +- JSON output shape from command handlers |
| 15 | +- deterministic exit codes |
| 16 | +- no interactive prompt loops (clarification requests return exit code `2`) |
26 | 17 |
|
27 | 18 | ## CLI Pipeline |
28 | 19 |
|
29 | 20 | ```bash |
30 | | -extropy spec → extropy scenario → extropy persona → extropy sample → extropy network → extropy simulate → extropy results |
| 21 | +extropy spec -> extropy scenario -> extropy persona -> extropy sample -> extropy network -> extropy simulate -> extropy results |
31 | 22 | ``` |
32 | 23 |
|
33 | | - |
34 | | -| Command | Purpose | |
35 | | -| ---------- | ------------------------------------------------ | |
36 | | -| `spec` | Create population spec from description | |
37 | | -| `scenario` | Create scenario with events and outcomes | |
38 | | -| `persona` | Generate persona rendering config | |
39 | | -| `sample` | Sample agents from merged spec | |
40 | | -| `network` | Generate social network | |
41 | | -| `simulate` | Run simulation | |
42 | | -| `results` | View results (summary, timeline, segment, agent) | |
43 | | -| `query` | Export raw data (agents, edges, states, SQL) | |
44 | | -| `chat` | Chat with simulated agents | |
45 | | -| `estimate` | Predict simulation cost | |
46 | | -| `validate` | Validate spec files | |
47 | | -| `config` | View/set configuration | |
48 | | - |
| 24 | +| Command | Purpose | |
| 25 | +|---------|---------| |
| 26 | +| `spec` | Create/iterate `population.vN.yaml` | |
| 27 | +| `scenario` | Create/iterate `scenario/{name}/scenario.vN.yaml` | |
| 28 | +| `persona` | Generate `persona.vN.yaml` for a scenario | |
| 29 | +| `sample` | Sample agents from merged base + extended attributes | |
| 30 | +| `network` | Build social graph for sampled agents | |
| 31 | +| `simulate` | Run timestep simulation | |
| 32 | +| `results` | Read run outcomes (`summary`, `timeline`, `segment`, `agent`) | |
| 33 | +| `query` | Export/query raw DB-backed entities | |
| 34 | +| `chat` | Chat with simulated agents (`list`, `ask`) | |
| 35 | +| `validate` | Validate population/scenario/persona YAML | |
| 36 | +| `config` | View/set configuration | |
49 | 37 |
|
50 | 38 | ## Non-Interactive Usage |
51 | 39 |
|
52 | | -### Pre-supplying answers |
53 | | - |
54 | | -For `spec` command, use `--answers` to skip clarification prompts: |
55 | | - |
56 | | -```bash |
57 | | -extropy spec "German surgeons" -o surgeons --answers '{"location": "Bavaria"}' |
58 | | -``` |
59 | | - |
60 | | -Or use `--use-defaults` to accept default values: |
| 40 | +### Pre-supply clarifications |
61 | 41 |
|
62 | 42 | ```bash |
| 43 | +extropy spec "German surgeons" -o surgeons --answers '{"location":"Bavaria"}' |
63 | 44 | extropy spec "German surgeons" -o surgeons --use-defaults |
64 | 45 | ``` |
65 | 46 |
|
66 | 47 | ### Skip confirmations |
67 | 48 |
|
68 | | -Use `-y` / `--yes` to skip confirmation prompts: |
69 | | - |
70 | 49 | ```bash |
71 | | -extropy scenario "AI adoption" -o ai-adoption -y |
72 | | -extropy persona -s ai-adoption -y |
| 50 | +extropy scenario "AI adoption in radiology" -o ai-radiology -y |
| 51 | +extropy persona -s ai-radiology -y |
73 | 52 | ``` |
74 | 53 |
|
75 | 54 | ## Exit Codes |
76 | 55 |
|
77 | | - |
78 | | -| Code | Meaning | |
79 | | -| ---- | ---------------------------------- | |
80 | | -| 0 | Success | |
81 | | -| 1 | General error / validation failure | |
82 | | -| 2 | Clarification needed (agent mode) | |
83 | | -| 3 | File not found | |
84 | | -| 4 | Sampling error | |
85 | | -| 5 | Network error | |
86 | | -| 6 | Simulation error | |
87 | | -| 7 | Scenario error | |
88 | | -| 10 | User cancelled | |
89 | | - |
| 56 | +| Code | Meaning | |
| 57 | +|------|---------| |
| 58 | +| `0` | Success | |
| 59 | +| `1` | Validation/general error | |
| 60 | +| `2` | Clarification required (agent mode) | |
| 61 | +| `3` | File/study/scenario not found | |
| 62 | +| `4` | Sampling error | |
| 63 | +| `5` | Network error | |
| 64 | +| `6` | Simulation error | |
| 65 | +| `7` | Scenario error | |
| 66 | +| `10` | User cancelled | |
90 | 67 |
|
91 | 68 | ## Querying Data |
92 | 69 |
|
93 | | -Export raw data for downstream processing: |
94 | | - |
95 | 70 | ```bash |
96 | | -# Agents as JSONL (auto-resolves scenario from latest run) |
97 | | -extropy query agents --to agents.jsonl |
98 | | - |
99 | | -# Explicit scenario |
100 | | -extropy query agents -s congestion-tax --to agents.jsonl |
| 71 | +# study/entity summary |
| 72 | +extropy query summary |
101 | 73 |
|
102 | | -# Network edges |
| 74 | +# agents / edges / states export (JSONL) |
| 75 | +extropy query agents --to agents.jsonl |
103 | 76 | extropy query edges --to edges.jsonl |
104 | | - |
105 | | -# Simulation states |
106 | 77 | extropy query states --to states.jsonl |
107 | 78 |
|
108 | | -# Arbitrary SQL (read-only) |
109 | | -extropy query sql "SELECT * FROM agent_states WHERE aware = 1" --format json |
| 79 | +# read-only SQL |
| 80 | +extropy query sql "SELECT run_id, status FROM simulation_runs ORDER BY started_at DESC LIMIT 5" --format json |
110 | 81 | ``` |
111 | 82 |
|
112 | 83 | ## Chat API |
113 | 84 |
|
114 | | -Non-interactive chat for automation: |
115 | | - |
116 | 85 | ```bash |
117 | | -extropy chat ask \ |
118 | | - --agent-id agent_042 \ |
119 | | - --prompt "What changed your mind?" \ |
120 | | - --json |
121 | | -``` |
122 | | - |
123 | | -List available agents: |
| 86 | +# list recent runs and sample agents |
| 87 | +extropy chat list |
124 | 88 |
|
125 | | -```bash |
126 | | -extropy chat list --json |
| 89 | +# non-interactive chat turn |
| 90 | +extropy chat ask --run-id <run_id> --agent-id <agent_id> --prompt "What changed your mind?" |
127 | 91 | ``` |
128 | 92 |
|
129 | | -**Note:** The interactive REPL (`extropy chat`) requires a TTY and is not suitable for automation. Use `extropy chat ask` instead. |
| 93 | +Note: REPL chat mode is not for automation. Use `chat ask`. |
130 | 94 |
|
131 | 95 | ## Configuration Keys |
132 | 96 |
|
133 | 97 | ```bash |
134 | | -extropy config set cli.mode agent # Enable agent mode globally |
135 | | -extropy config set models.strong openai/gpt-5 |
136 | | -extropy config set models.fast openai/gpt-5-mini |
137 | | -extropy config set simulation.strong anthropic/claude-sonnet-4-6 |
138 | | -extropy config set show_cost true # Show cost after commands |
| 98 | +# output behavior |
| 99 | +extropy config set cli.mode agent |
| 100 | + |
| 101 | +# pipeline models (spec/scenario/persona) |
| 102 | +extropy config set models.fast anthropic/claude-sonnet-4-6 |
| 103 | +extropy config set models.strong anthropic/claude-sonnet-4-6 |
| 104 | + |
| 105 | +# simulation models (reasoning/classification) |
| 106 | +extropy config set simulation.strong azure/gpt-5-mini |
| 107 | +extropy config set simulation.fast azure/gpt-5-mini |
| 108 | + |
| 109 | +# runtime controls |
| 110 | +extropy config set simulation.rate_tier 2 |
| 111 | +extropy config set show_cost true |
139 | 112 | ``` |
140 | 113 |
|
141 | 114 | ## Environment Variables |
142 | 115 |
|
143 | | -Required API keys (set at least one): |
| 116 | +Set at least one provider key used by your configured models: |
144 | 117 |
|
145 | 118 | ```bash |
146 | 119 | export OPENAI_API_KEY=sk-... |
147 | 120 | export ANTHROPIC_API_KEY=sk-ant-... |
148 | 121 | export OPENROUTER_API_KEY=sk-or-... |
149 | 122 | export DEEPSEEK_API_KEY=sk-... |
| 123 | + |
| 124 | +# Azure (supported names) |
150 | 125 | export AZURE_API_KEY=... |
151 | 126 | export AZURE_ENDPOINT=https://<resource>.services.ai.azure.com/ |
| 127 | +# Legacy aliases still supported: |
| 128 | +# AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT |
152 | 129 | ``` |
153 | 130 |
|
154 | 131 | ## Global Flags |
155 | 132 |
|
156 | | -All commands accept: |
157 | | - |
158 | | - |
159 | | -| Flag | Purpose | |
160 | | -| -------------- | -------------------------------- | |
161 | | -| `--json` | JSON output (overrides cli.mode) | |
162 | | -| `--cost` | Show cost summary after command | |
163 | | -| `--study PATH` | Explicit study folder path | |
164 | | - |
| 133 | +| Flag | Purpose | |
| 134 | +|------|---------| |
| 135 | +| `--version` | Print version and exit | |
| 136 | +| `--cost` | Show command cost footer | |
| 137 | +| `--study PATH` | Explicit study folder path | |
165 | 138 |
|
166 | 139 | ## Study Folder Structure |
167 | 140 |
|
168 | 141 | ``` |
169 | 142 | my-study/ |
170 | | -├── study.db # Canonical SQLite store |
171 | | -├── population.v1.yaml # Base population spec |
| 143 | +├── study.db |
| 144 | +├── population.v1.yaml |
172 | 145 | ├── scenario/ |
173 | 146 | │ └── my-scenario/ |
174 | | -│ ├── scenario.v1.yaml # Scenario spec |
175 | | -│ └── persona.v1.yaml # Persona config |
| 147 | +│ ├── scenario.v1.yaml |
| 148 | +│ └── persona.v1.yaml |
176 | 149 | └── results/ |
177 | | - └── my-scenario/ # Simulation outputs |
| 150 | + └── my-scenario/ |
178 | 151 | ``` |
179 | 152 |
|
180 | 153 | ## Typical Automation Flow |
181 | 154 |
|
182 | 155 | ```bash |
183 | | -# Create study folder and setup agent mode |
| 156 | +# 1) Create study + base population |
184 | 157 | extropy spec "Austin TX commuters" -o my-study --use-defaults |
185 | 158 | cd my-study |
186 | 159 | extropy config set cli.mode agent |
187 | 160 |
|
188 | | -# Build scenario |
189 | | -extropy scenario "Congestion tax response" -o congestion-tax -y |
| 161 | +# 2) Build scenario + persona |
| 162 | +extropy scenario "Congestion pricing response" -o congestion-tax -y |
190 | 163 | extropy persona -s congestion-tax -y |
191 | 164 |
|
192 | | -# Sample agents and generate network (LLM config by default) |
193 | | -extropy sample -s congestion-tax -n 500 --seed 42 |
194 | | -extropy network -s congestion-tax --seed 42 |
195 | | - |
196 | | -# Estimate before running |
197 | | -extropy estimate -s congestion-tax --json |
| 165 | +# 3) Sample and network |
| 166 | +extropy sample -s congestion-tax -n 500 --seed 42 --strict-gates |
| 167 | +extropy network -s congestion-tax --seed 42 --quality-profile balanced --validate |
198 | 168 |
|
199 | | -# Run simulation |
200 | | -extropy simulate -s congestion-tax --seed 42 |
| 169 | +# 4) Simulate |
| 170 | +extropy simulate -s congestion-tax --seed 42 --fidelity medium |
201 | 171 |
|
202 | | -# Extract results |
203 | | -extropy results --json |
204 | | -extropy query agents --to agents.jsonl |
| 172 | +# 5) Read outputs |
| 173 | +extropy results -s congestion-tax summary |
| 174 | +extropy results -s congestion-tax timeline |
205 | 175 | extropy query states --to states.jsonl |
206 | 176 | ``` |
207 | | - |
0 commit comments