affaan-m/ECC · error · RuntimeError

claude -p returned empty output

Error message

claude -p returned empty output

What it means

generate_scenarios() checks for a non-zero return code first (error 547), then checks for an empty stdout. This message fires when claude -p succeeded (rc=0) but emitted only whitespace — there is no YAML to extract_scenario scenarios from.

Source

Thrown at skills/skill-comply/scripts/scenario_generator.py:54

    prompt_template = (PROMPTS_DIR / "scenario_generator.md").read_text()
    prompt = (
        prompt_template
        .replace("{skill_content}", skill_content)
        .replace("{spec_yaml}", spec_yaml)
    )

    result = subprocess.run(
        ["claude", "-p", prompt, "--model", model, "--output-format", "text"],
        capture_output=True,
        text=True,
        timeout=120,
    )

    if result.returncode != 0:
        raise RuntimeError(f"claude -p failed: {result.stderr}")

    if not result.stdout.strip():
        raise RuntimeError("claude -p returned empty output")

    raw_yaml = extract_yaml(result.stdout)
    parsed = yaml.safe_load(raw_yaml)

    scenarios: list[Scenario] = []
    for s in parsed["scenarios"]:
        scenarios.append(Scenario(
            id=s["id"],
            level=s["level"],
            level_name=s["level_name"],
            description=s["description"],
            prompt=s["prompt"].strip(),
            setup_commands=tuple(s.get("setup_commands", [])),
        ))

    return sorted(scenarios, key=lambda s: s.level)

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Re-run the same command manually and inspect stdout/stderr.
  2. Shorten the skill content or spec_yaml fed into the prompt template.
  3. Switch model to a stronger one (e.g. sonnet) that is more likely to complete.
  4. Check the scenario_generator.md prompt template for unfilled placeholders that may confuse the model.

Example fix

# before
scenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')

# after
try:
    scenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')
except RuntimeError as e:
    if 'empty output' in str(e):
        scenarios = generate_scenarios(skill_path, spec_yaml, model='sonnet')
    else:
        raise
Defensive patterns

Strategy: fallback

Try / catch

from scripts.scenario_generator import generate_scenarios
try:
    scenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')
except RuntimeError as e:
    if 'empty output' in str(e):
        scenarios = generate_scenarios(skill_path, spec_yaml, model='sonnet')
    else:
        raise

Prevention

When it happens

Trigger: The model returned an empty completion; a content filter stripped the output; the prompt template produced an empty user turn; stream/format mismatch where the CLI returned its content on stderr instead of stdout.

Common situations: An over-long prompt that hit the model's output cap and returned nothing; a safety filter triggered by the assembled skill/spec content; a CLI version that emits text output differently than expected.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/732660c3811b318a. Report an issue: GitHub.