File size: 11,956 Bytes
9d0ae22
 
 
 
 
 
 
 
 
1c25e79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
---
title: FlowOs V2
emoji: 📚
colorFrom: red
colorTo: green
sdk: docker
pinned: false
---

# FlowOS V2

FlowOS V2 is an OpenEnv environment for training LLM agents to build and repair realistic data-platform workflows. Instead of solving a toy grid world, the agent has to read workspace files, inspect schemas, write pipeline YAML and SQL, run validators, interpret runtime failures, and submit a working warehouse report.

- Hugging Face Space: [praanjal-flowos-v2.hf.space](https://praanjal-flowos-v2.hf.space)
- OpenEnv manifest: [openenv.yaml](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/openenv.yaml)
- Training scripts:
  - [collect_traces.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/collect_traces.py)
  - [train_sft.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/train_sft.py)
  - [train.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/train.py)
  - [eval.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/eval.py)
- Plotting script: [plot_metrics.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/plot_metrics.py)
- Blog / writeup: `ADD_HF_BLOG_LINK_HERE`
- Video / slides: `ADD_VIDEO_OR_SLIDES_LINK_HERE`

## Problem

LLM agents still struggle with one of the most common production engineering loops:

1. understand a partially specified data task,
2. create the right pipeline artifacts,
3. run the workflow,
4. interpret runtime failures,
5. repair the broken pieces without violating downstream contracts.

Most existing agent benchmarks either stop at code generation or use abstract environments with low-stakes actions. FlowOS instead targets a concrete capability gap: can an LLM learn to behave like a junior-to-mid-level data platform engineer working in a shared production workspace?

We care about this because modern analytics teams constantly perform exactly this pattern:
- generate ingestion or reporting pipelines from imperfect specs,
- debug warehouse jobs and broken transforms,
- preserve schema contracts while fixing failures,
- coordinate between different responsibilities like “builder” and “fixer”.

## Environment

FlowOS V2 is built on the latest OpenEnv stack and exposed as a remote environment on Hugging Face Spaces.

The current submission focuses on a simulation task family called `simulate_csv_report_workflow`. Each episode places the agent in a small but realistic workspace with:

- a source CSV,
- runtime instructions,
- schema files,
- editable pipeline targets:
  - `pipelines/report_job.yaml`
  - `sql/load_raw.sql`
  - `sql/build_table.sql`
  - `sql/report_view.sql`

The environment then runs those artifacts against a local DuckDB-backed execution runtime and returns:

- runtime success / failure,
- execution logs,
- output schema,
- preview rows,
- validator results.

### What the agent sees

On each step, the agent receives:

- the developer request,
- workspace summary,
- known files,
- editable targets,
- visible schema assets,
- validator names,
- current role (`builder` or `fixer`),
- runtime feedback from prior edits.

### What the agent can do

The agent can:

- `read_file`
- `inspect_schema`
- `edit_file`
- `run_validator`
- `submit_workspace`

### What gets rewarded

The reward and grading logic combines:

- investigation quality,
- artifact completeness,
- runtime success,
- final schema correctness,
- summary quality,
- successful submission.

This is implemented through OpenEnv-compatible state, validator, and grader flows in:

- [tasks.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/tasks.py)
- [graders.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/graders.py)
- [runtime.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/runtime.py)
- [server/developer_control_room_environment.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/server/developer_control_room_environment.py)

## Scenarios

The simulation task currently has 7 deterministic scenarios:

### Pipeline generation

- `SIM-001`: build a customer daily sales report
- `SIM-002`: build a subscription daily report
- `SIM-003`: build an inventory movement report

### Pipeline repair

- `SIM-004`: repair a broken customer-order build SQL
- `SIM-005`: repair a broken subscription report contract
- `SIM-006`: repair a broken inventory report schema
- `SIM-007`: fix a builder-created returns pipeline after runtime failure

This mix was chosen to test both:

- first-pass workflow construction,
- and second-pass repair under runtime feedback.

## Why this environment is interesting

We think this environment is novel because it sits between code generation and full production ops:

- it is not just “write SQL”,
- it is not just “fix a syntax bug”,
- and it is not a toy planning problem.

The agent has to coordinate file creation, schema understanding, runtime-aware debugging, and role-aware behavior inside a shared workspace. That makes it a better fit for training practical engineering agents than many one-shot coding benchmarks.

## Training pipeline

We currently support two training directions:

### 1. Stable path: supervised fine-tuning

This is the main path we are using for reproducible training evidence.

1. Collect teacher traces from the environment:

```bash
python collect_traces.py \
  --env-url https://praanjal-flowos-v2.hf.space \
  --task-scope simulate_csv_report_workflow \
  --dataset-size 28 \
  --max-turns 12 \
  --output-dir outputs/sft_traces_v2
```

2. Train a LoRA SFT policy:

```bash
CUDA_VISIBLE_DEVICES=0 python train_sft.py \
  --dataset-path outputs/sft_traces_v2/traces.jsonl \
  --model-id Qwen/Qwen2.5-1.5B-Instruct \
  --output-dir outputs/flowos-sft-v2 \
  --num-epochs 2 \
  --per-device-train-batch-size 1 \
  --gradient-accumulation-steps 4 \
  --max-seq-length 1024 \
  --load-in-4bit \
  --gradient-checkpointing
```

### 2. Experimental path: GRPO / TRL

We also have an RL-style training entrypoint in [train.py](/Users/pranjalparashar/Desktop/hackz/cw-apr1/control-room/developer_control_room/train.py) for future work, but the current submission story is centered on the stable SFT path because it is the most reproducible on commodity GPUs.

## Results

The main question for this environment is simple:

**Does a trained policy behave better than an untrained one?**

To answer that, we compare:

- the base model,
- the fine-tuned checkpoint,
- and optionally the same evaluation with fallback disabled for a stricter policy-only check.

### Evaluation command

```bash
python eval.py \
  --model-id Qwen/Qwen2.5-1.5B-Instruct \
  --checkpoint-path outputs/flowos-sft-v2 \
  --env-url https://praanjal-flowos-v2.hf.space \
  --task-scope simulate_csv_report_workflow \
  --episodes 7 \
  --max-turns 12 \
  --results-dir outputs/eval_compare_v2
```

### Plot generation

```bash
python plot_metrics.py \
  --train-metrics outputs/flowos-sft-v2/training_metrics.csv \
  --eval-metrics outputs/eval_compare_v2/eval_episode_metrics.csv \
  --output-dir outputs/plots_v2
```

### Current evidence

The repository now saves:

- training loss curves,
- per-episode evaluation metrics,
- average reward / score / solved-rate comparisons,
- fallback-step and valid-model-step comparisons,
- generated pipeline artifacts for inspection.

Replace the placeholders below with the final PNGs from your latest run:

- `ADD_TRAINING_LOSS_PLOT_HERE`
- `ADD_EVAL_SCORE_PLOT_HERE`
- `ADD_EVAL_SOLVED_RATE_PLOT_HERE`
- `ADD_BASELINE_VS_TRAINED_TABLE_HERE`

Recommended final README embed format:

```md
![SFT training loss](assets/plots/sft_training_loss.png)
![Average score by policy](assets/plots/eval_avg_score.png)
![Solved rate by policy](assets/plots/eval_solved_rate.png)
```

## How to try the environment

### Run the Space locally

```bash
uv run server
```

### Run a quick environment check

```bash
python -c "from developer_control_room.server.developer_control_room_environment import DeveloperControlRoomEnvironment as E; env=E(); obs=env.reset(task_id='simulate_csv_report_workflow', scenario_index=0); print(obs.scenario_id, obs.active_role, obs.known_files)"
```

### Run evaluation

```bash
python eval.py \
  --model-id Qwen/Qwen2.5-1.5B-Instruct \
  --env-url https://praanjal-flowos-v2.hf.space \
  --task-scope simulate_csv_report_workflow \
  --episodes 1 \
  --max-turns 12 \
  --debug-actions
```

## Submission materials

Please link all final materials here before submission:

- Hugging Face Space: [https://praanjal-flowos-v2.hf.space](https://praanjal-flowos-v2.hf.space)
- Hugging Face blog: `ADD_HF_BLOG_LINK_HERE`
- Video / slides: `ADD_VIDEO_OR_SLIDES_LINK_HERE`
- Colab notebook: `ADD_COLAB_LINK_HERE`

## Future multi-agent architecture

The current environment already has the beginnings of role-aware coordination through the `builder` / `fixer` split. If we extend this into a fuller multi-agent setup with specialized agents like:

- database agent,
- deployment agent,
- pipeline authoring agent,
- incident / fixer agent,

then the architecture should change in a few important ways.

### 1. Role-specific observations and action spaces

Today, all roles see roughly the same workspace shape. In a fuller multi-agent system we would want:

- role-specific observations,
- role-specific allowed actions,
- role-specific reward components.

Example:
- database agent should inspect schemas, SQL, and warehouse outputs,
- deployment agent should inspect configs, schedules, and orchestrator state,
- fixer agent should receive richer runtime and incident logs.

### 2. Shared workspace plus shared memory

We already have a shared workspace. A multi-agent version would also need explicit shared memory for:

- handoff notes,
- failure summaries,
- pending tasks,
- ownership / lock state for files or resources.

That prevents agents from overwriting one another blindly and makes coordination trainable.

### 3. Agent routing / orchestration layer

We would need a coordinator that decides:

- which specialist acts next,
- whether the current role should continue,
- when to escalate from builder to fixer,
- when to stop and submit.

This could be:

- a learned scheduler,
- a rule-based router,
- or another LLM agent acting as a planner.

### 4. Role-conditioned reward design

The reward function should separate:

- local role success,
- global workflow success,
- coordination quality.

For example:
- builder gets rewarded for producing a coherent first-pass pipeline,
- fixer gets rewarded for resolving runtime failures quickly,
- coordinator gets rewarded for minimizing unnecessary turns and handoffs.

### 5. Runtime modularization

As specialized agents grow, the runtime should stop looking like a single flat executor and instead expose modular subsystems:

- warehouse / DuckDB runtime,
- deployment / orchestrator runtime,
- validator runtime,
- artifact registry.

That would let different specialist agents act on different subsystems while still contributing to a shared final score.

### 6. Explicit communication channels

If we want the multi-agent behavior to be a real benchmark and not just sequential role labels, we should add:

- message passing or notes between agents,
- structured handoff actions,
- maybe role-specific submission or escalation actions.

That would make coordination itself part of what gets trained.

## Why this matters

Production AI agents will not succeed only by writing one perfect file. They will need to:

- work in partially broken systems,
- preserve contracts under pressure,
- coordinate across roles,
- and improve through training rather than prompt tricks alone.

FlowOS V2 is our attempt to make that trainable in a compact but realistic OpenEnv environment.