1. Prepare Your Task App
- Write or pick a TaskAppConfig (a
.pyfile that registers your app insynth_ai.task.apps.registry). - Create an
.envfile containing at least:Usesynth-ai setupor a password manager to keep these up to date. - Sanity-check the app locally (optional but recommended). Set an output directory so successful rollouts can emit JSONL immediately:
This starts uvicorn, enables tracing by default, and ensures the basic endpoints respond. Stop here if the app fails; SFT data collection depends on a healthy task app.
2. Deploy for Rollouts
Pick the runtime best suited for the collection session:- Local (
--runtime local): fastest iteration while you develop. Tracing is auto-enabled; setTASKAPP_SFT_OUTPUT_DIRto choose where JSONL batches land (for exampletraces/sft_records). - Modal (
--runtime modal): deploys to Modal servers so teammates can collect rollouts or run larger batches. Provide--modal-appand (optionally)--nameto map to an existing Modal config.
SYNTH_API_KEY and ENVIRONMENT_API_KEY are loaded (from the CLI environment or the supplied .env), and prints the URL of the running task app. Keep that URL for the rollout step.
3. Collect Rollouts with Tracing Enabled
Rollouts are what power SFT. You can gather them manually, via automation, or by sharing the task app with labelers:- Confirm tracing is still on. Local deploys run with
--traceenabled by default, soTASKAPP_TRACING_ENABLED=1. You must setTASKAPP_SFT_OUTPUT_DIR(orSFT_OUTPUT_DIR) yourself before launching if you want JSONL written to disk; otherwiseresolve_sft_output_dir()returnsNoneand the task app will skip SFT dumps. Tracing_v3 automatically provisions a SQLite database undertraces/(seeTRACE_DB_DIRinsynth_ai/tracing_v3/constants.py). Modal deploys rely on your Modal app’s tracing settings; export the same env vars there if you need local JSONLs. - Point your collector at the task app. Common options:
uvx synth-ai eval ... --task-app-url <URL>to run scripted rollouts.- Custom agents or labeler tools hitting
/rolloutand/states.
- Run enough variety. Aim for dozens to hundreds of sessions that demonstrate the behaviors you care about. The tracing backend records:
- Session metadata (model, env, seed, scores, timestamps)
- Message streams (system/user/assistant/tool turns)
- Outcome rewards and judge scores if your app sets them
- Verify traces exist:
- Inspect the directory you pointed
TASKAPP_SFT_OUTPUT_DIRat (for exampletraces/sft_records) to make sure JSONL batches are appearing. - Look under
traces/for the trace database file (default names referenceTRACE_DB_DIR) or whatever path you configured; confirm its timestamp updates as you run rollouts. - For Modal deployments, download the trace DB or connect via the remote database URL that your Modal app prints.
- Inspect the directory you pointed
4. Export SFT JSONL with synth-ai filter
Once you have traces, convert them into training examples:
- Write a
[filter]TOML describing where to read from and where to write (pointdbat whichever.dbfile lives under yourTRACE_DB_DIR, for exampletraces/trace_records.dbor a timestamped variant):Supported filter knobs include:splits,task_ids,models- Score thresholds (
min_official_score,max_official_score, per-judge min/max) - Time windows (
min_created_at,max_created_at), pagination (limit,offset), shuffle/shuffle_seed
- Run the filter command:
- Validates the config (
FilterConfig) and ensuresoutputends with.jsonlor.json. - Connects to the tracing DB via
SessionTracer. - Applies your filters session by session.
- Emits one JSONL record per qualifying conversation turn, each shaped like:
- Review the output: open a few rows to confirm the instructions/responses look correct and that metadata contains the fields you need downstream.
5. Validate the Dataset Before Training
The SFT CLI automatically validates JSONL files, but you can pre-check them to catch issues early:- Each line is valid JSON with at least one message.
- Roles are limited to
system,user,assistant, ortool. - Tool definitions/calls include required names/function signatures when present.
- Multimodal payloads follow the structure expected by the trainer.
6. Next Steps: Train with synth-ai train --type sft
With a validated JSONL, you can update your SFT config to point at the new dataset (or pass --dataset to the CLI) and launch training:
- Validate the dataset again.
- Upload it to the Synth backend.
- Create and start the learning job.
- Stream progress (
train.loss, validation summaries) until completion.
Checklist
- Task app validated (local or Modal) via
synth-ai deploy. - Tracing enabled (JSONL directory + trace DB confirmed).
- Rollouts collected with diverse prompts and seeds.
- Filter TOML written and run; JSONL exported with expected metadata.
- Dataset validated with
validate_sft_jsonl. - SFT config points to the new dataset, ready for
synth-ai train.