runtime-reflexion

runtime-reflexion is a skill for Claude Code, Codex from topprismdata/cultivating-ml-agent. It costs 66 tokens per session (930 once invoked), scanned A, original, MIT.

A method for running generated Python code, classifying its errors, and retrying with a suggested correction. It groups failures such as missing packages, memory limits, and incompatible data shapes into diagnosis categories.

In plain words
What is it for?
Use it when sandboxed Python experiments fail, generated machine-learning code raises errors, or an automated agent needs a diagnose-and-retry loop.
Why use it?
It helps an agent respond to runtime failures systematically instead of getting stuck after the first failed execution.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when sandboxed Python experiments fail, generated machine-learning code raises errors, or an automated agent needs a diagnose-and-retry loop.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/topprismdata/cultivating-ml-agent/runtime-reflexion
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add topprismdata/cultivating-ml-agent --skill runtime-reflexion
Clone the repo
git clone --depth 1 https://github.com/topprismdata/cultivating-ml-agent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for runtime-reflexion

README.md
[![agentmods](https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/runtime-reflexion/github.svg)](https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/runtime-reflexion)
Your own site
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/runtime-reflexion"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/runtime-reflexion/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for runtime-reflexion

Your own site · 80×15
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/runtime-reflexion"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/runtime-reflexion.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 930 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00066 $0.00930
Opus 5.5 $0.00026 $0.00372
Sonnet 5.5 $0.00013 $0.00186
Haiku 4.5 $0.00007 $0.00093

Measured 3mo ago against content hash d14f537a23b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

runtime-reflexion scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/examples/runtime-reflexion/SKILL.md · 100 lines

How it starts

The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Runtime Reflexion (Error → Diagnose → Retry)

Context

Static skills freeze knowledge. Reflexion (Shinn et al. NeurIPS 2023) + Code Sandbox makes ML agents self-correct: 80%+ of runtime errors auto-fixable when errors are precisely classified. agy verified this as a P0 must-have for ML agents (MLE-bench Kaggle medal correlation).

The core insight: errors aren't random — they fall into ~12 categories, each with known fixes.

Guidance

Single Execution with Diagnosis

from framework.src.reflexion import CodeSandbox, ErrorAnalyzer, execute_with_analysis

sandbox = CodeSandbox(timeout_sec=30)
result, diagnosis = execute_with_analysis(generated_code, sandbox)

if not result.success:
    print(f"Error: {diagnosis.category.value}")
    print(f"Suggested fix: {diagnosis.suggested_fix}")
    print(f"Related skills: {diagnosis.related_skills}")
    # → "category=memory, fix=reduce batch_size, skills=[gpu-readiness-assessment]"

Self-Correction Loop

from framework.src.reflexion import ReflexionLoop, CodeSandbox

def my_llm_fix(prompt: str) -> str:
    """Call Claude/your LLM to fix code given the reflexion prompt"""
    return llm_client.messages.create(
        model="claude-sonnet-4-6",
        messages=[{"role": "user", "content": prompt}],
    ).content[0].text

loop = ReflexionLoop(
    sandbox=CodeSandbox(timeout_sec=60),
    llm_fix=my_llm_fix,
)
result = loop.run(initial_code, max_attempts=5)

if result.success:
    deploy(result.final_code)
else:
    log_to_vault(result.final_diagnosis)  # remember for next time

Error Categories (12)

Category Trigger Fix
syntax SyntaxError Check indentation
import ModuleNotFoundError pip install
shape shape mismatch reshape/transpose
memory CUDA OOM reduce batch_size
overfitting val_loss diverging dropout/early stop
data_leakage "leakage" mentioned check temporal features
timeout timed out reduce data/optimize
... ... ...

Read the full file on GitHub · 100 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 100 lines · 66 tokens per session scan A d14f537a23b8

Subscribe to this mod's changes

runtime-reflexion is a skill published in the GitHub repository topprismdata/cultivating-ml-agent (5 stars, last pushed 1mo ago), licensed MIT. It adds 66 tokens to every session and 930 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

runtime-reflexion compared with skills from other repositories

runtime-reflexion next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
runtime-reflexiontopprismdata/cultivating-ml-agentSkill51mo agoMITA66Claude Code, Codex
python-output-buffering-background-scriptstopprismdata/agent-nurture-frameworkSkill31mo agoMITA153Claude Code, Codex
huggingface-hubbraxtonROSE4/zorro-agentSkill117mo agoMITC43Claude Code, Codex
agent-v3-memory-specialistruvnet/rufloSkill83ktodayMITA25Claude Code
neural-trainingruvnet/rufloSkill83ktodayMITA64Claude Code
reward-designbojieli/ai-agent-bookSkill60kyesterdayApache-2.0A131Claude Code, Codex
agent-evolutionbojieli/ai-agent-bookSkill60kyesterdayApache-2.0A126Claude Code, Codex