# RLM: Self-Refinement
# Recursive improvement until quality threshold

input artifact: "The artifact to refine"
input criteria: "Quality criteria"

agent evaluator:
  model: sonnet
  prompt: "Score 0-100 against criteria. List specific issues."

agent refiner:
  model: opus
  prompt: "Make targeted improvements. Preserve what works."

block refine(content, depth):
  if depth <= 0:
    output content

  let eval = session: evaluator
    prompt: "Evaluate against: {criteria}"
    context: content

  if **score >= 85**:
    output content

  let improved = session: refiner
    prompt: "Fix the identified issues"
    context: { artifact: content, evaluation: eval }

  output do refine(improved, depth - 1)

output result = do refine(artifact, 5)
