{"record":{"id":"732660c3811b318a","repo":"affaan-m/ECC","slug":"claude-p-returned-empty-output","errorCode":null,"errorMessage":"claude -p returned empty output","messagePattern":"claude -p returned empty output","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"skills/skill-comply/scripts/scenario_generator.py","lineNumber":54,"sourceCode":"    prompt_template = (PROMPTS_DIR / \"scenario_generator.md\").read_text()\n    prompt = (\n        prompt_template\n        .replace(\"{skill_content}\", skill_content)\n        .replace(\"{spec_yaml}\", spec_yaml)\n    )\n\n    result = subprocess.run(\n        [\"claude\", \"-p\", prompt, \"--model\", model, \"--output-format\", \"text\"],\n        capture_output=True,\n        text=True,\n        timeout=120,\n    )\n\n    if result.returncode != 0:\n        raise RuntimeError(f\"claude -p failed: {result.stderr}\")\n\n    if not result.stdout.strip():\n        raise RuntimeError(\"claude -p returned empty output\")\n\n    raw_yaml = extract_yaml(result.stdout)\n    parsed = yaml.safe_load(raw_yaml)\n\n    scenarios: list[Scenario] = []\n    for s in parsed[\"scenarios\"]:\n        scenarios.append(Scenario(\n            id=s[\"id\"],\n            level=s[\"level\"],\n            level_name=s[\"level_name\"],\n            description=s[\"description\"],\n            prompt=s[\"prompt\"].strip(),\n            setup_commands=tuple(s.get(\"setup_commands\", [])),\n        ))\n\n    return sorted(scenarios, key=lambda s: s.level)\n","sourceCodeStart":36,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/skills/skill-comply/scripts/scenario_generator.py#L36-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the same command manually and inspect stdout/stderr.","Shorten the skill content or spec_yaml fed into the prompt template.","Switch model to a stronger one (e.g. sonnet) that is more likely to complete.","Check the scenario_generator.md prompt template for unfilled placeholders that may confuse the model."],"exampleFix":"# before\nscenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')\n\n# after\ntry:\n    scenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')\nexcept RuntimeError as e:\n    if 'empty output' in str(e):\n        scenarios = generate_scenarios(skill_path, spec_yaml, model='sonnet')\n    else:\n        raise","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from scripts.scenario_generator import generate_scenarios\ntry:\n    scenarios = generate_scenarios(skill_path, spec_yaml, model='haiku')\nexcept RuntimeError as e:\n    if 'empty output' in str(e):\n        scenarios = generate_scenarios(skill_path, spec_yaml, model='sonnet')\n    else:\n        raise","preventionTips":["Use a stronger model (sonnet/opus) when prompt complexity is high so the model completes.","Trim skill/spec content fed into the prompt to reduce the chance of empty completions.","Treat empty stdout as a signal to shorten the input, not just to retry blindly."],"tags":["subprocess","claude-cli","skill-comply","scenario-generator","empty-response"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}