{"record":{"id":"ddc0c4090d647a48","repo":"calesthio/OpenMontage","slug":"music-gen-estimate-cost-duration-seconds-is-requi","errorCode":null,"errorMessage":"music_gen.estimate_cost: duration_seconds is required. Derive it from the approved target runtime in the script/proposal. Silent defaults are not permitted.","messagePattern":"music_gen\\.estimate_cost: duration_seconds is required\\. Derive it from the approved target runtime in the script/proposal\\. Silent defaults are not permitted\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/audio/music_gen.py","lineNumber":105,"sourceCode":"        cpu_cores=1, ram_mb=256, vram_mb=0, disk_mb=50, network_required=True\n    )\n    retry_policy = RetryPolicy(max_retries=2, retryable_errors=[\"rate_limit\", \"timeout\"])\n    idempotency_key_fields = [\"prompt\", \"duration_seconds\"]\n    side_effects = [\"writes audio file to output_path\", \"calls ElevenLabs API\"]\n    user_visible_verification = [\n        \"Listen to generated music for mood and quality\",\n    ]\n\n    def get_status(self) -> ToolStatus:\n        if os.environ.get(\"ELEVENLABS_API_KEY\"):\n            return ToolStatus.AVAILABLE\n        return ToolStatus.UNAVAILABLE\n\n    def estimate_cost(self, inputs: dict[str, Any]) -> float:\n        # ElevenLabs music generation pricing is per generation\n        duration = inputs.get(\"duration_seconds\")\n        if duration is None:\n            raise ValueError(\n                \"music_gen.estimate_cost: duration_seconds is required. \"\n                \"Derive it from the approved target runtime in the script/proposal. \"\n                \"Silent defaults are not permitted.\"\n            )\n        # Approximate: ~$0.05 per 30 seconds\n        return round(duration / 30 * 0.05, 4)\n\n    def execute(self, inputs: dict[str, Any]) -> ToolResult:\n        api_key = os.environ.get(\"ELEVENLABS_API_KEY\")\n        if not api_key:\n            return ToolResult(\n                success=False,\n                error=\"No ElevenLabs API key. \" + self.install_instructions,\n            )\n\n        start = time.time()\n\n        try:","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/audio/music_gen.py#L87-L123","documentation":"Raised by music_gen.estimate_cost when inputs lacks duration_seconds. ElevenLabs music pricing is approximated per 30 seconds of runtime ($0.05/30s), so a duration is mandatory; the project explicitly forbids silent defaults because cost approval must be grounded in the approved target runtime from the script/proposal.","triggerScenarios":"Planner/orchestrator calls estimate_cost before duration is known; inputs assembled from a template without the runtime field; execute-time cost accounting hitting the same check.","commonSituations":"Automated cost-preview passes that probe tools with incomplete inputs; new pipeline stages added before the script's runtime is approved; key named differently (duration, length_seconds).","solutions":["Derive duration_seconds from the approved target runtime in the script/proposal and pass it in inputs","Order pipeline stages so cost estimation runs after runtime approval","Add an upstream schema check that fails fast listing duration_seconds as required"],"exampleFix":"// before\ninputs = {\"prompt\": \"cinematic intro\"}\ntool.estimate_cost(inputs)  # raises\n\n// after\ninputs = {\"prompt\": \"cinematic intro\", \"duration_seconds\": 60}\ntool.estimate_cost(inputs)  # 0.1","handlingStrategy":"validation","validationCode":"duration = inputs.get(\"duration_seconds\")\nif duration is None:\n    raise ValueError(\n        \"duration_seconds required: derive from the approved target runtime in the script/proposal\"\n    )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run cost estimation only after the script's runtime is approved","Never default duration silently — the project forbids it by design","Add a required-fields schema check for music_gen inputs at the orchestrator"],"tags":["elevenlabs","music","cost-estimation","validation"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}