Convergence optimization loop: optimize a metric through targeted, incremental changes. Supports command-based and LLM-judged metrics, tmux/interactive modes, direction awareness.
Start the Pickle Rick microverse convergence loop — optimize a metric through targeted, incremental changes. Defaults to tmux mode; use --interactive for inline.
Proceed to Step 1.
SPEAK BEFORE ACTING: Output text before every tool call.
pickle_state.py init instead of setup.jspickle_state.py update instead of update-state.jsdelegate_task instead of spawning subprocessesmux_runner.pyhermes -q per iteration instead of claude -pExtract from user input:
| Flag | Default | Required (new) | Description |
|---|---|---|---|
--metric "<cmd>" | — | Yes (XOR --goal) | Shell command whose last stdout line is a numeric score. Sets type='command'. |
--goal "<text>" | — | Yes (XOR --metric) | Natural language goal for LLM judge. Sets type='llm'. |
--direction <higher|lower> | higher | No | Optimization direction — whether higher or lower scores are better |
--judge-model <model> | claude-sonnet-4-6 | No | Judge model for LLM scoring (only valid with --goal) |
--task "<text>" | — | Yes | What to optimize (becomes the PRD objective) |
--tolerance <N> | 0 | No | Score delta within which changes count as "held" |
--stall-limit <N> | 5 | No | Non-improving iterations before convergence |
--max-iterations <N> | 500 | No | Hard cap on total iterations |
--resume [path] | — | No | Resume existing session (skips --metric/--task/--goal) |
--interactive | — | No | Run inline instead of tmux (default is tmux mode) |
If --resume: --metric/--goal and --task are NOT required.
Otherwise:
--metric or --goal is required — print error and STOP if both or neither provided.--task is required — print error and STOP if missing.--judge-model without --goal is an error — print error and STOP.python3 ~/.hermes/skills/autonomous-ai-agents/pickle-rick/scripts/setup.js" --command-template microverse.md --tmux [--max-iterations <N>] --task "<TASK_TEXT>"
If --interactive flag was passed, omit --tmux from the init call.
python3 ~/.hermes/skills/autonomous-ai-agents/pickle-rick/scripts/setup.js" --command-template microverse.md --resume [<PATH>] --tmux [--max-iterations <N>]
If --interactive flag was passed, omit --tmux from the init call.
Extract SESSION_ROOT=<path> from output. If --resume, skip Steps 3 and 4.
Write ${SESSION_ROOT}/microverse.json conforming to MicroverseSessionState:
node -e "
const fs = require('fs');
const path = require('path');
const sessionDir = process.argv[1];
const type = process.argv[6] || 'command';
const direction = process.argv[7] || 'higher';
const keyMetric = {
description: process.argv[2],
validation: process.argv[3],
type: type,
timeout_seconds: 60,
tolerance: Number(process.argv[4]),
direction: direction
};
if (type === 'llm') keyMetric.judge_model = process.argv[8] || 'claude-sonnet-4-6';
const state = {
status: 'gap_analysis',
prd_path: path.join(sessionDir, 'prd.md'),
key_metric: keyMetric,
convergence: {
stall_limit: Number(process.argv[5]),
stall_counter: 0,
history: []
},
gap_analysis_path: '',
failed_approaches: [],
baseline_score: 0
};
fs.writeFileSync(path.join(sessionDir, 'microverse.json'), JSON.stringify(state, null, 2));
console.log('microverse.json created');
" "${SESSION_ROOT}" "<TASK_TEXT>" "<VALIDATION>" "<TOLERANCE>" "<STALL_LIMIT>" "<TYPE>" "<DIRECTION>" "<JUDGE_MODEL>"
Replace placeholders with parsed values:
<VALIDATION> = metric command (if --metric) or goal text (if --goal)<TYPE> = command (if --metric) or llm (if --goal)<DIRECTION> = from --direction flag (default higher)<JUDGE_MODEL> = from --judge-model flag (default claude-sonnet-4-6, only used when type=llm)Verify: node -e "const s=JSON.parse(require('fs').readFileSync('${SESSION_ROOT}/microverse.json','utf-8')); console.log('status:', s.status, 'metric:', s.key_metric.validation, 'stall_limit:', s.convergence.stall_limit)"
Write ${SESSION_ROOT}/prd.md:
# Microverse Optimization PRD
## Objective
<TASK_TEXT>
## Key Metric
- **Type**: <TYPE> (`command` or `llm`)
- **Command** (if type=command): `<METRIC_CMD>`
- **Goal** (if type=llm): <GOAL_TEXT>
- **Direction**: <DIRECTION> (higher or lower is better)
- **Tolerance**: <TOLERANCE>
- **Stall Limit**: <STALL_LIMIT>
## Success Criteria
Continuously improve the metric score through targeted, incremental changes until convergence (no improvement for <STALL_LIMIT> consecutive iterations).
## Constraints
- One logical change per iteration
- Never repeat failed approaches
- Always commit changes for measurement
- Metric is measured automatically after each iteration
--interactive flag)Check tmux: tmux -V. If missing → print "Install tmux: brew install tmux" and STOP.
Session name: microverse-<hash> from SESSION_ROOT basename.
Read working_dir from ${SESSION_ROOT}/state.json.
Create tmux session:
tmux new-session -d -s <name> -c <working_dir>
sleep 1
Print attach command: tmux attach -t <name>
tmux send-keys -t <name>:0 "python3 ~/.hermes/skills/autonomous-ai-agents/pickle-rick/scripts/microverse-runner.js ${SESSION_ROOT}; echo ''; echo 'Microverse runner finished. Ctrl+B 1 → monitor | Ctrl+B D → detach'; read" Enter
bash ~/.hermes/skills/autonomous-ai-agents/pickle-rick/scripts/tmux-monitor.sh" <name> ${SESSION_ROOT} pickle
tmux attach -t <name>, window layout (monitor: Ctrl+B 1; runner: Ctrl+B 0), cancel: cd <working_dir> && eat-pickle, emergency: tmux kill-session -t <name>, state path.Output: [TASK_COMPLETED]
--interactive flag present)You ARE the convergence loop. Run it inline.
${SESSION_ROOT}/prd.md${SESSION_ROOT}/gap_analysis.mdmicroverse.json: set gap_analysis_path to the gap analysis pathgit add -A && git commit -m "microverse: gap analysis and initial improvements"baseline_score in microverse.jsonmicroverse.json: set status to "iterating"Repeat until converged or max iterations reached:
microverse.json for current stategit rev-parse HEADfailed_approaches to avoid repeats, review recent convergence.history for trendscommand: Run the metric validation command, parse the numeric score from the last linellm: Do NOT run the validation as a shell command. The runner's LLM judge scores your changes — note this and proceed to commit. The judge will evaluate against the goal description.key_metric.direction:
higher (default):
git reset --hard <pre-iteration-SHA>, add description to failed_approaches, increment stall_counterlower:
git reset --hard <pre-iteration-SHA>, add description to failed_approaches, increment stall_countergit add -A && git commit -m "microverse: <description>"convergence.history: {iteration, metric_value, score, action, description, pre_iteration_sha, timestamp}microverse.jsonstall_counter >= stall_limit → set status to "converged", exit loop"stopped", set exit_reason to "limit_reached", exit loopmicroverse.json with final status and exit_reason[TASK_COMPLETED]failed_approaches before planning