FLYWHEEL
TASK-LEVEL REINFORCEMENT LEARNING

Every outcome
sharpens the next.

A tiny, dependency-free RL brain that learns which approach wins for each task type — and recommends the best next move.

Turn every outcome into a policy update. FLYWHEEL generalizes proven bandit math (win-rate·0.6 + avg-reward·0.4 + exploration + count-decay) from 'which model wins' to 'which action wins for THIS task type', so each thing your agent does biases the next decision. Recall the best past approach; reward outcomes; exploit and explore. Zero dependencies, atomic writes, never throws.

reinforcement-learning bandit grpo policy zero-deps self-improving
what it does

A learning loop in two files.

01 / RECORD

Reward every outcome

Call record(taskType, action, reward) after anything your agent does. It appends an observation and updates a bounded policy. Low-confidence judgments are logged but never drift the calibration.

02 / REINFORCE

A policy that adapts

Each action's score blends win-rate, average reward, an under-sampling exploration bonus, and a nudge to re-check stale winners. Old counts decay so the policy never ossifies.

03 / RECOMMEND

Ask what wins

recommend(taskType, actions) returns the best learned action with a reason — exploit a proven winner or explore an untried one. Group K variants through GRPO to get critic-free advantages.

quickstart

Up and running in a clone.

Every value comes from .env. Nothing here is tied to any account — bring your own.

# 1. no install needed — pure Node builtins
node lib/group-advantage.cjs      # runs the GRPO self-test

# 2. watch the policy learn from rewards
node examples/demo.cjs

# 3. inspect / drive the brain from the CLI
node lib/flywheel.cjs recommend build react vue svelte
node lib/flywheel.cjs record build react 0.9 "shipped clean"
node lib/flywheel.cjs policy build