{"record":{"id":"97c3b53f21149dbc","repo":"invoke-ai/InvokeAI","slug":"call-saved-workflow-exceeds-remaining-queue-capaci-97c3b5","errorCode":null,"errorMessage":"call_saved_workflow exceeds remaining queue capacity for child workflow executions","messagePattern":"call_saved_workflow exceeds remaining queue capacity for child workflow executions","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/session_processor/workflow_call_runtime.py","lineNumber":78,"sourceCode":"            \"field_values\": field_values,\n        }\n        if hasattr(queue_item, \"model_copy\"):\n            return queue_item.model_copy(update=child_updates)\n\n        child_queue_item = type(queue_item).__new__(type(queue_item))\n        child_queue_item.__dict__ = {**queue_item.__dict__, **child_updates}\n        return child_queue_item\n\n    def begin_workflow_call_boundary(\n        self,\n        invocation: CallSavedWorkflowInvocation,\n        queue_item: SessionQueueItem,\n        workflow_record,\n    ) -> SessionQueueItem:\n        queue_status = self._session_runner._services.session_queue.get_queue_status(queue_item.queue_id)\n        remaining_queue_capacity = self._session_runner._services.configuration.max_queue_size - queue_status.pending\n        if remaining_queue_capacity <= 0:\n            raise ValueError(\"call_saved_workflow exceeds remaining queue capacity for child workflow executions\")\n\n        call_frame = queue_item.session.build_workflow_call_frame(invocation.id, invocation.workflow_id)\n        workflow_inputs = self._collect_call_saved_workflow_inputs(invocation, queue_item)\n        child_session_results = build_child_workflow_session_results(\n            parent_session=queue_item.session,\n            workflow=workflow_record.workflow.model_dump(),\n            workflow_inputs=workflow_inputs,\n            call_frame=call_frame,\n            maximum_children=remaining_queue_capacity,\n            services=self._session_runner._services,\n            user_id=getattr(queue_item, \"user_id\", None),\n        )\n        child_sessions = [child_result.session for child_result in child_session_results]\n        if len(child_sessions) > remaining_queue_capacity:\n            raise ValueError(\"call_saved_workflow exceeds remaining queue capacity for child workflow executions\")\n        queue_item.session.begin_waiting_on_workflow_call(call_frame)\n        queue_item.session.attach_waiting_workflow_call_child_sessions(child_sessions)\n        child_queue_item = None","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/session_processor/workflow_call_runtime.py#L60-L96","documentation":"begin_workflow_call_boundary checks the session queue status before expanding a called workflow: remaining capacity = max_queue_size - pending. If nothing is left (<= 0), it raises ValueError immediately instead of building children that could not be enqueued.","triggerScenarios":"Calling a saved workflow via call_saved_workflow while the queue is at or over configuration.max_queue_size pending items — get_queue_status().pending >= max_queue_size.","commonSituations":"Busy shared queue at max_queue_size; max_queue_size lowered in config while jobs are pending; burst submissions exhausting capacity; test fixtures enqueuing items up to the cap.","solutions":["Wait for or cancel pending queue items until capacity frees, then retry the call.","Increase configuration.max_queue_size to accommodate the expected child count plus current pending load.","Catch this ValueError and surface a 'queue full' user message with a retry/backoff, e.g. poll get_queue_status before submitting.","Pre-check capacity yourself: services.session_queue.get_queue_status(qid).pending < services.configuration.max_queue_size - expected_children."],"exampleFix":"// before\nchild = coordinator.run(...)  # raises when queue full\n// after\nstatus = services.session_queue.get_queue_status(qid)\nif services.configuration.max_queue_size - status.pending <= 0:\n    raise QueueFull(...)  # or wait and retry","handlingStrategy":"validation","validationCode":"status = services.session_queue.get_queue_status(queue_item.queue_id)\nremaining = services.configuration.max_queue_size - status.pending\nif remaining <= 0:\n    raise QueueFullError(\"wait for queue capacity before workflow call\")","typeGuard":"def has_queue_capacity(services, needed=1) -> bool:\n    status = services.session_queue.get_queue_status(status.queue_id)\n    return services.configuration.max_queue_size - status.pending >= needed","tryCatchPattern":"try:\n    child = begin_workflow_call_boundary(...)\nexcept ValueError as e:\n    if \"exceeds remaining queue capacity\" in str(e):\n        await wait_for_capacity(...); retry()","preventionTips":["Poll get_queue_status before submitting workflow calls","Set max_queue_size with headroom for child fan-out","Implement client-side backoff/retry on capacity errors","Watch pending counts in multi-user deployments"],"tags":["invokeai","queue","workflow-call","capacity"],"backgroundTag":"queue-capacity-exceeded","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}