Generating mod learning envs
Use this skill to create JSON envs consumed by /mods learn --env=<path> or bun scripts/mod-learning/learn-mod.ts --env <path>. An env describes the mod behavior to learn and the scenario-suite eval used to score candidates.
Workflow
- Define the behavior and eval before writing JSON.
- What should the mod do? Tool, turn event, tool event, provider, command, status, etc.
- What would a placebo/no-op mod fail?
- What unique sentinel strings make success unambiguous?
- Choose a path:
- Repo example:
docs/examples/mods/learning/<slug>.env.json
- Local/private: any user-requested path
- Draft strict JSON. Start from
assets/mod-learning-env.template.json if useful. No comments or trailing commas.
- Prefer
evaluation.scenarios with at least:
- happy path
- discrimination/exact-target path
- negative control
- Validate:
bun src/skills/builtin/generating-mod-envs/scripts/validate-mod-env.ts path/to/env.json
If this skill is installed outside the source tree, run the same script from this skill directory: scripts/validate-mod-env.ts.
- If asked to run it:
/mods learn --env=path/to/env.json --model=auto --backend=api --out=/tmp/<slug>-learn
The raw scripts/mod-learning/learn-mod.ts dev script detaches by default. Add --foreground only when a blocking pass/fail exit code is needed.
Use single-line --flag=value commands for TUI instructions.
Env shape
Required top-level fields:
name: human display name.
slug: stable kebab-case run/candidate slug.
objective: one-paragraph target for the generation agent.
requirements: concrete pass/fail behavior constraints.
evaluation: either a single prompt eval or a scenario suite.
Common optional fields:
targetModName: display metadata for the intended mod filename. The harness still chooses the candidate filename from slug unless --candidate-file-name is passed.
candidateDiversityHints: strategies assigned across multi-candidate runs.
modApiHints: concise API reminders that prevent bad generated code.
examples: small input/expected demos for the generation prompt.
Evaluation fields:
evaluation.outputFormat: use stream-json when checking trace markers.
evaluation.timeoutMs, evaluation.maxTurns: per-scenario defaults.
evaluation.memoryFiles: files seeded under eval $MEMORY_DIR.
evaluation.scenarios[]: scenario-specific overrides and fixtures.
- In scenario-suite envs, do not add a top-level
evaluation.prompt unless that prompt must run for every scenario. Assertion-only scenarios should have assertions and no prompt; only scenarios that require model behavior should define scenario.prompt.
requiredResultMarkers: literal strings required in the final answer.
requiredTraceMarkers: literal strings required in raw stdout/stderr.
forbiddenResultMarkers: final-answer strings that fail the run.
forbiddenTraceMarkers: raw trace strings that fail the run.
Quality rules
- Design the eval first. A useful env distinguishes success from a no-op mod.
- Use unique sentinels, e.g.
MY-MOD-CANARY-OK, not common phrases.
- Seed
memoryFiles rather than depending on real user memory or repo files.
- Include negative controls for non-use. If behavior should be conditional, verify it stays silent when not triggered.
- Include discrimination scenarios when paths, IDs, or sources matter. Put a tempting wrong sentinel in an irrelevant fixture and forbid it in the final answer.
- Put load failures in
forbiddenTraceMarkers, usually:
[mods] failed to load
[extensions] failed to load
loaded 0 mod(s)
loaded 0 extension(s)
- For eval-facing tools, require
requiresApproval: false, parallelSafe: true, and a strict no-argument schema when applicable.
- Avoid over-brittle trace markers. Prefer stable substrings like the tool name plus
"message_type":"tool_return_message".
- Keep requirements behavioral; put fragile implementation details in
modApiHints only when needed.
Minimal scenario-suite example
{
"name": "Hello tool mod learner demo",
"slug": "hello-tool",
"objective": "Learn a trusted local mod that registers a read-only hello_mod_ping tool returning a fixed sentinel.",
"requirements": [
"Register a tool named hello_mod_ping.",
"The tool must accept no parameters, require no approval, be parallelSafe, and return the exact string HELLO-MOD-OK."
],
"candidateDiversityHints": [
"Use the smallest possible tool-only implementation.",
"Add explicit defensive checks around the tool schema."
],
"modApiHints": [
"Use export function activate(letta) or a default export.",
"Use letta.tools.register({ name, description, parameters, requiresApproval, parallelSafe, run }).",
"A no-argument tool schema is { \"type\": \"object\", \"properties\": {}, \"additionalProperties\": false }."
],
"evaluation": {
"outputFormat": "stream-json",
"timeoutMs": 900000,
"maxTurns": 6,
"forbiddenTraceMarkers": ["[mods] failed to load", "loaded 0 mod(s)"],
"scenarios": [
{
"name": "happy-path",
"prompt": "Call the hello_mod_ping tool, then answer with the exact text HELLO-MOD-OK.",
"requiredResultMarkers": ["HELLO-MOD-OK"],
"requiredTraceMarkers": ["hello_mod_ping", "\"message_type\":\"tool_return_message\""]
},
{
"name": "negative-control",
"prompt": "Answer without calling tools: what is 2 + 2?",
"requiredResultMarkers": ["4"],
"forbiddenTraceMarkers": ["hello_mod_ping"]
}
]
}
}
1---2name: generating-mod-envs3description: Generates and reviews mod learning env JSON files for Letta Code local mods. Use when asked to teach, learn, or optimize a mod behavior; create, draft, validate, improve, or explain envs for `/mods learn --env`; or design evaluation scenarios, memory fixtures, requiredResultMarkers, requiredTraceMarkers, negative controls, and candidate diversity hints.4---56# Generating mod learning envs78Use this skill to create JSON envs consumed by `/mods learn --env=<path>` or `bun scripts/mod-learning/learn-mod.ts --env <path>`. An env describes the mod behavior to learn and the scenario-suite eval used to score candidates.910## Workflow11121. Define the behavior and eval before writing JSON.13 - What should the mod do? Tool, turn event, tool event, provider, command, status, etc.14 - What would a placebo/no-op mod fail?15 - What unique sentinel strings make success unambiguous?162. Choose a path:17 - Repo example: `docs/examples/mods/learning/<slug>.env.json`18 - Local/private: any user-requested path193. Draft strict JSON. Start from `assets/mod-learning-env.template.json` if useful. No comments or trailing commas.204. Prefer `evaluation.scenarios` with at least:21 - happy path22 - discrimination/exact-target path23 - negative control245. Validate:2526```bash27bun src/skills/builtin/generating-mod-envs/scripts/validate-mod-env.ts path/to/env.json28```2930If this skill is installed outside the source tree, run the same script from this skill directory: `scripts/validate-mod-env.ts`.31326. If asked to run it:3334```text35/mods learn --env=path/to/env.json --model=auto --backend=api --out=/tmp/<slug>-learn36```3738The raw `scripts/mod-learning/learn-mod.ts` dev script detaches by default. Add `--foreground` only when a blocking pass/fail exit code is needed.3940Use single-line `--flag=value` commands for TUI instructions.4142## Env shape4344Required top-level fields:4546- `name`: human display name.47- `slug`: stable kebab-case run/candidate slug.48- `objective`: one-paragraph target for the generation agent.49- `requirements`: concrete pass/fail behavior constraints.50- `evaluation`: either a single prompt eval or a scenario suite.5152Common optional fields:5354- `targetModName`: display metadata for the intended mod filename. The harness still chooses the candidate filename from `slug` unless `--candidate-file-name` is passed.55- `candidateDiversityHints`: strategies assigned across multi-candidate runs.56- `modApiHints`: concise API reminders that prevent bad generated code.57- `examples`: small input/expected demos for the generation prompt.5859Evaluation fields:6061- `evaluation.outputFormat`: use `stream-json` when checking trace markers.62- `evaluation.timeoutMs`, `evaluation.maxTurns`: per-scenario defaults.63- `evaluation.memoryFiles`: files seeded under eval `$MEMORY_DIR`.64- `evaluation.scenarios[]`: scenario-specific overrides and fixtures.65- In scenario-suite envs, do not add a top-level `evaluation.prompt` unless that prompt must run for every scenario. Assertion-only scenarios should have `assertions` and no `prompt`; only scenarios that require model behavior should define `scenario.prompt`.66- `requiredResultMarkers`: literal strings required in the final answer.67- `requiredTraceMarkers`: literal strings required in raw stdout/stderr.68- `forbiddenResultMarkers`: final-answer strings that fail the run.69- `forbiddenTraceMarkers`: raw trace strings that fail the run.7071## Quality rules7273- Design the eval first. A useful env distinguishes success from a no-op mod.74- Use unique sentinels, e.g. `MY-MOD-CANARY-OK`, not common phrases.75- Seed `memoryFiles` rather than depending on real user memory or repo files.76- Include negative controls for non-use. If behavior should be conditional, verify it stays silent when not triggered.77- Include discrimination scenarios when paths, IDs, or sources matter. Put a tempting wrong sentinel in an irrelevant fixture and forbid it in the final answer.78- Put load failures in `forbiddenTraceMarkers`, usually:79 - `[mods] failed to load`80 - `[extensions] failed to load`81 - `loaded 0 mod(s)`82 - `loaded 0 extension(s)`83- For eval-facing tools, require `requiresApproval: false`, `parallelSafe: true`, and a strict no-argument schema when applicable.84- Avoid over-brittle trace markers. Prefer stable substrings like the tool name plus `"message_type":"tool_return_message"`.85- Keep requirements behavioral; put fragile implementation details in `modApiHints` only when needed.8687## Minimal scenario-suite example8889```json90{91 "name": "Hello tool mod learner demo",92 "slug": "hello-tool",93 "objective": "Learn a trusted local mod that registers a read-only hello_mod_ping tool returning a fixed sentinel.",94 "requirements": [95 "Register a tool named hello_mod_ping.",96 "The tool must accept no parameters, require no approval, be parallelSafe, and return the exact string HELLO-MOD-OK."97 ],98 "candidateDiversityHints": [99 "Use the smallest possible tool-only implementation.",100 "Add explicit defensive checks around the tool schema."101 ],102 "modApiHints": [103 "Use export function activate(letta) or a default export.",104 "Use letta.tools.register({ name, description, parameters, requiresApproval, parallelSafe, run }).",105 "A no-argument tool schema is { \"type\": \"object\", \"properties\": {}, \"additionalProperties\": false }."106 ],107 "evaluation": {108 "outputFormat": "stream-json",109 "timeoutMs": 900000,110 "maxTurns": 6,111 "forbiddenTraceMarkers": ["[mods] failed to load", "loaded 0 mod(s)"],112 "scenarios": [113 {114 "name": "happy-path",115 "prompt": "Call the hello_mod_ping tool, then answer with the exact text HELLO-MOD-OK.",116 "requiredResultMarkers": ["HELLO-MOD-OK"],117 "requiredTraceMarkers": ["hello_mod_ping", "\"message_type\":\"tool_return_message\""]118 },119 {120 "name": "negative-control",121 "prompt": "Answer without calling tools: what is 2 + 2?",122 "requiredResultMarkers": ["4"],123 "forbiddenTraceMarkers": ["hello_mod_ping"]124 }125 ]126 }127}128```