Agent RL Sandbox Trainer
Design safe, measurable agent-learning loops for specific coding behaviors.
Use This For
- Building a simulation sandbox where an agent practices narrow actions such as claim-before-edit, failing-test repair, reviewer reply drafting, or safe dependency updates.
- Turning successful and failed trajectories into supervised, preference, RFT, or QLoRA/LoRA training data.
- Designing eval gates, reward functions, unhooks, and rollback paths before any adapted agent reaches real repos.
- Reviewing whether a behavior should be trained, scripted, prompted, or left to human review.
Do Not Use This For
- Training a model because a prompt is inconvenient.
- Rewarding "looks plausible" without ground-truth state checks.
- Letting an adapted agent bypass the same sandbox, claims, budget, and review gates as a base agent.
Training Loop
flowchart TD
A[Choose one behavior] --> B[Build sandbox task]
B --> C[Record trajectories]
C --> D[Score with eval harness]
D --> E{Prompt or script enough?}
E -->|Yes| F[Ship prompt/script]
E -->|No| G[Create SFT/DPO/RFT/QLoRA plan]
G --> H[Gate adapted agent on held-out evals]
H --> I[Deploy behind unhooks]
- Choose one observable behavior. Good examples: "claim files before edit," "run focused tests before PR," "stop when credentials are missing."
- Build a sandbox with disposable repo state, deterministic fixtures, fake credentials, and a reset command.
- Define reward from artifacts, not prose: file claims exist, tests pass, dangerous command refused, PR reply contains evidence.
- Record traces as state, action, observation, reward, and unhook. Keep failed traces; they teach the boundary.
- Run
scripts/trajectory_eval_harness.mjs before any training export.
- Pick the lightest intervention that passes: rule, script, skill, small adapter, then RFT. QLoRA is for repeated behavior gaps on local/open models, not every product bug.
- Deploy adapted behavior only behind eval gates, kill switches, budget caps, and rollback unhooks.
QLoRA / RL Practical Guidance
- LoRA freezes the base model and trains low-rank adapter matrices; QLoRA adds 4-bit quantization so larger models can be adapted with less memory.
- For coding agents, the valuable data is often not final code but trajectories: commands, observations, tool choices, refusals, tests, and reviewer feedback.
- Use behavior cloning or SFT for "do this consistently." Use preference/RFT when the reward is measurable but the path can vary.
- Never train directly on production secrets, private customer code, or hidden policy bypasses. Redact, synthesize, or replay in fixtures.
Anti-Patterns
Training Around A Missing Button
Novice: "Fine-tune the agent to remember this workflow."
Expert: If the behavior is deterministic, build a script, command, hook, or UI affordance first. Train only when the agent must generalize across varied states.
Detection: The desired behavior can be expressed as a simple if/then rule.
Rewarding The Transcript, Not The World
Novice: "The agent said tests passed, so reward it."
Expert: Reward the verified state: test output, file diff, claim row, command exit code, review thread reply, or sandbox reset.
Detection: Eval harness accepts self-reported success.
Adapter Without Unhooks
Novice: "The adapter improved the benchmark, ship it."
Expert: Adapted agents need disable switches, model fallback, per-behavior rollout, held-out evals, and audit logs.
Detection: No rollback path or comparison against base-agent behavior.
References
| File |
Load When |
references/rl-sandbox-architecture.md |
Need sandbox, trajectory, reward, QLoRA, and unhook architecture. |
references/eval-examples.md |
Need concrete behavior curricula and eval rows. |
examples/expected-output.md |
Need a finished training-plan example. |
templates/output-template.md |
Need a reusable training-plan template. |
schemas/reward-spec.schema.json |
Need to validate reward options such as action ordering and deployment gates. |
schemas/trajectory-suite.schema.json |
Need to validate trajectory/eval inputs. |
scripts/trajectory_eval_harness.mjs |
Need deterministic trajectory scoring. |
scripts/preflight.sh |
Need safe local environment inspection before running examples. |
agents/openai.yaml |
Need a subagent descriptor for delegated RL sandbox design. |
Skill Bundle Index
Every file in this skill, and when to open it. Auto-generated by the repo skill-architect indexer.
root
CHANGELOG.md — Agent Rl Sandbox Trainer — Changelog — - Initial skill creation - Core process defined - Reference files added
README.md — Agent RL Sandbox Trainer — Procedural guidance for building deterministic simulation sandboxes, trajectory eval harnesses, adapter-training plans, and unhooks for spec
agents/
agents/openai.yaml — openai (data/schema)
examples/
examples/expected-output.md — Example Output: Agent RL Sandbox Trainer — Train or tune a reviewer-fix agent to respond to PR review comments with code changes, focused tests, and a substantive reply, without broad
references/
references/eval-examples.md — Eval Examples — Use this when writing behavior curricula.
references/rl-sandbox-architecture.md — RL Sandbox Architecture For Coding Agents — Use this when designing a training or eval loop.
schemas/
schemas/reward-spec.schema.json — reward spec.schema (data/schema)
schemas/trajectory-suite.schema.json — trajectory suite.schema (data/schema)
scripts/
scripts/preflight.sh — !/usr/bin/env bash
scripts/trajectory_eval_harness.mjs
templates/
templates/output-template.md — Agent RL Sandbox Training Spec — [Specific behavior the base agent cannot perform reliably enough.] - Repo/app state: [fixture] - Allowed tools: [tool list] - Forbidden tool
1---2name: agent-rl-sandbox-trainer3description: >-4 Design RL simulation sandboxes, trajectory datasets, QLoRA/LoRA adaptation plans, eval harnesses, and rollback unhooks5 for agents learning specific coding behaviors beyond the base model. Use when building or reviewing tool-use training6 loops, offline trajectories, reward functions, self-improvement harnesses, or Port Daddy agent behavior curricula. NOT7 for generic ML tutorials, full model training operations, or production deployment without eval gates and safety unhooks.8license: Apache-2.09allowed-tools: Read,Write,Edit,Bash(node:*,npm:test,python3:*)10metadata:11 source: https://skillmd.com/skills/curiositech/agent-rl-sandbox-trainer12 category: AI & Machine Learning13 tags:14 - rl15 - qlora16 - evals17 - agent-training18 - simulation19 provenance:20 kind: first-party21 owners:22 - port-daddy23 pairs-with:24 - skill: runtime-verification-for-agents25 reason: Training changes need runtime invariants and safety checks.26 - skill: output-contract-enforcer27 reason: Eval rows and trajectories must be schema-valid before downstream use.28 - skill: swarm-invocation-designer29 reason: Learned behaviors must fit the coordination protocol.30 io-contract:31 kind: deliverable32 consumes:33 - kind: trajectory-suite34 format: json35 - kind: reward-spec36 format: json37 produces:38 - kind: eval-report39 format: json40 - kind: training-plan41 format: markdown42 - kind: rollback-unhook-plan43 format: markdown44---4546# Agent RL Sandbox Trainer4748Design safe, measurable agent-learning loops for specific coding behaviors.4950## Use This For5152- Building a simulation sandbox where an agent practices narrow actions such as claim-before-edit, failing-test repair, reviewer reply drafting, or safe dependency updates.53- Turning successful and failed trajectories into supervised, preference, RFT, or QLoRA/LoRA training data.54- Designing eval gates, reward functions, unhooks, and rollback paths before any adapted agent reaches real repos.55- Reviewing whether a behavior should be trained, scripted, prompted, or left to human review.5657## Do Not Use This For5859- Training a model because a prompt is inconvenient.60- Rewarding "looks plausible" without ground-truth state checks.61- Letting an adapted agent bypass the same sandbox, claims, budget, and review gates as a base agent.6263## Training Loop6465```mermaid66flowchart TD67 A[Choose one behavior] --> B[Build sandbox task]68 B --> C[Record trajectories]69 C --> D[Score with eval harness]70 D --> E{Prompt or script enough?}71 E -->|Yes| F[Ship prompt/script]72 E -->|No| G[Create SFT/DPO/RFT/QLoRA plan]73 G --> H[Gate adapted agent on held-out evals]74 H --> I[Deploy behind unhooks]75```76771. Choose one observable behavior. Good examples: "claim files before edit," "run focused tests before PR," "stop when credentials are missing."782. Build a sandbox with disposable repo state, deterministic fixtures, fake credentials, and a reset command.793. Define reward from artifacts, not prose: file claims exist, tests pass, dangerous command refused, PR reply contains evidence.804. Record traces as state, action, observation, reward, and unhook. Keep failed traces; they teach the boundary.815. Run `scripts/trajectory_eval_harness.mjs` before any training export.826. Pick the lightest intervention that passes: rule, script, skill, small adapter, then RFT. QLoRA is for repeated behavior gaps on local/open models, not every product bug.837. Deploy adapted behavior only behind eval gates, kill switches, budget caps, and rollback unhooks.8485## QLoRA / RL Practical Guidance8687- LoRA freezes the base model and trains low-rank adapter matrices; QLoRA adds 4-bit quantization so larger models can be adapted with less memory.88- For coding agents, the valuable data is often not final code but trajectories: commands, observations, tool choices, refusals, tests, and reviewer feedback.89- Use behavior cloning or SFT for "do this consistently." Use preference/RFT when the reward is measurable but the path can vary.90- Never train directly on production secrets, private customer code, or hidden policy bypasses. Redact, synthesize, or replay in fixtures.9192## Anti-Patterns9394### Training Around A Missing Button9596**Novice**: "Fine-tune the agent to remember this workflow."97**Expert**: If the behavior is deterministic, build a script, command, hook, or UI affordance first. Train only when the agent must generalize across varied states.98**Detection**: The desired behavior can be expressed as a simple if/then rule.99100### Rewarding The Transcript, Not The World101102**Novice**: "The agent said tests passed, so reward it."103**Expert**: Reward the verified state: test output, file diff, claim row, command exit code, review thread reply, or sandbox reset.104**Detection**: Eval harness accepts self-reported success.105106### Adapter Without Unhooks107108**Novice**: "The adapter improved the benchmark, ship it."109**Expert**: Adapted agents need disable switches, model fallback, per-behavior rollout, held-out evals, and audit logs.110**Detection**: No rollback path or comparison against base-agent behavior.111112## References113114| File | Load When |115| --- | --- |116| `references/rl-sandbox-architecture.md` | Need sandbox, trajectory, reward, QLoRA, and unhook architecture. |117| `references/eval-examples.md` | Need concrete behavior curricula and eval rows. |118| `examples/expected-output.md` | Need a finished training-plan example. |119| `templates/output-template.md` | Need a reusable training-plan template. |120| `schemas/reward-spec.schema.json` | Need to validate reward options such as action ordering and deployment gates. |121| `schemas/trajectory-suite.schema.json` | Need to validate trajectory/eval inputs. |122| `scripts/trajectory_eval_harness.mjs` | Need deterministic trajectory scoring. |123| `scripts/preflight.sh` | Need safe local environment inspection before running examples. |124| `agents/openai.yaml` | Need a subagent descriptor for delegated RL sandbox design. |125126<!-- BEGIN BUNDLE INDEX (auto: index_references.py) -->127128## Skill Bundle Index129130*Every file in this skill, and when to open it. Auto-generated by the repo skill-architect indexer.*131132**root**133- [`CHANGELOG.md`](CHANGELOG.md) — Agent Rl Sandbox Trainer — Changelog — - Initial skill creation - Core process defined - Reference files added134- [`README.md`](README.md) — Agent RL Sandbox Trainer — Procedural guidance for building deterministic simulation sandboxes, trajectory eval harnesses, adapter-training plans, and unhooks for spec135136**`agents/`**137- [`agents/openai.yaml`](agents/openai.yaml) — openai (data/schema)138139**`examples/`**140- [`examples/expected-output.md`](examples/expected-output.md) — Example Output: Agent RL Sandbox Trainer — Train or tune a reviewer-fix agent to respond to PR review comments with code changes, focused tests, and a substantive reply, without broad141142**`references/`**143- [`references/eval-examples.md`](references/eval-examples.md) — Eval Examples — Use this when writing behavior curricula.144- [`references/rl-sandbox-architecture.md`](references/rl-sandbox-architecture.md) — RL Sandbox Architecture For Coding Agents — Use this when designing a training or eval loop.145146**`schemas/`**147- [`schemas/reward-spec.schema.json`](schemas/reward-spec.schema.json) — reward spec.schema (data/schema)148- [`schemas/trajectory-suite.schema.json`](schemas/trajectory-suite.schema.json) — trajectory suite.schema (data/schema)149150**`scripts/`**151- [`scripts/preflight.sh`](scripts/preflight.sh) — !/usr/bin/env bash152- [`scripts/trajectory_eval_harness.mjs`](scripts/trajectory_eval_harness.mjs)153154**`templates/`**155- [`templates/output-template.md`](templates/output-template.md) — Agent RL Sandbox Training Spec — [Specific behavior the base agent cannot perform reliably enough.] - Repo/app state: [fixture] - Allowed tools: [tool list] - Forbidden tool156157<!-- END BUNDLE INDEX -->