{"record":{"id":"eb49167b81af8b0f","repo":"multica-ai/multica","slug":"delete-runtime-runtime-has-active-agents-bound-to","errorCode":null,"errorMessage":"delete runtime: runtime has active agents bound to it (%s); rebind them to another runtime first, or rerun with --cascade to unbind them and delete the runtime (the agents and their history are kept)","messagePattern":"delete runtime: runtime has active agents bound to it \\((.+?)\\); rebind them to another runtime first, or rerun with --cascade to unbind them and delete the runtime \\(the agents and their history are kept\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/cmd/multica/cmd_runtime.go","lineNumber":240,"sourceCode":"\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\terr = client.DeleteJSON(ctx, \"/api/runtimes/\"+runtimeID)\n\tif err == nil {\n\t\treturn printRuntimeDeleteResult(cmd, map[string]any{\n\t\t\t\"id\":      runtimeID,\n\t\t\t\"deleted\": true,\n\t\t})\n\t}\n\n\tconflict, ok := runtimeDeleteConflict(err)\n\tif !ok {\n\t\treturn fmt.Errorf(\"delete runtime: %w\", err)\n\t}\n\n\tcascade, _ := cmd.Flags().GetBool(\"cascade\")\n\tif !cascade {\n\t\treturn fmt.Errorf(\n\t\t\t\"delete runtime: runtime has active agents bound to it (%s); rebind them to another runtime first, or rerun with --cascade to unbind them and delete the runtime (the agents and their history are kept)\",\n\t\t\tstrings.Join(conflict.AgentDisplays(), \", \"),\n\t\t)\n\t}\n\n\tbody := map[string]any{\n\t\t\"expected_active_agent_ids\": conflict.AgentIDs(),\n\t}\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/runtimes/\"+runtimeID+\"/unbind-agents-and-delete\", body, &result); err != nil {\n\t\treturn fmt.Errorf(\"cascade delete runtime: %w\", err)\n\t}\n\tresult[\"id\"] = runtimeID\n\tresult[\"deleted\"] = true\n\treturn printRuntimeDeleteResult(cmd, result)\n}\n\nfunc runRuntimeRename(cmd *cobra.Command, args []string) error {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_runtime.go#L222-L258","documentation":"The structured conflict branch of runRuntimeDelete: the server rejected DELETE /api/runtimes/{id} because active agents are still bound to the runtime, runtimeDeleteConflict parsed the agent list, and the --cascade flag was not passed. The message names the bound agents and offers the two supported resolutions: rebind them first, or rerun with --cascade to unbind and delete while preserving the agents and their history.","triggerScenarios":"Running `multica runtime delete <id>` (no --cascade) while at least one agent is actively bound to that runtime; typically after decommissioning a runtime that still serves live agents.","commonSituations":"Decommissioning a provider/runtime during migration without first migrating its agents; forgetting that --cascade exists; wanting a safe default — the guard is intentional so operators do not accidentally orphan live agents.","solutions":["Preferred: rebind the listed agents to another runtime first (multica agent bind/rebind or the API), then re-run the delete.","Alternatively: multica runtime delete <id> --cascade — the CLI then POSTs /unbind-agents-and-delete with expected_active_agent_ids; agents and history are kept, agents become unbound.","If unsure, list agents bound to the runtime before deciding which path fits your workflow."],"exampleFix":"# before\nmultica runtime delete rt_123\n# delete runtime: runtime has active agents bound to it (agent-a, agent-b); ...\n\n# after (option 1: rebind first)\nmultica agent rebind agent-a --runtime rt_9ab\nmultica agent rebind agent-b --runtime rt_9ab\nmultica runtime delete rt_123\n\n# after (option 2: cascade)\nmultica runtime delete rt_123 --cascade","handlingStrategy":"validation","validationCode":"cascade, _ := cmd.Flags().GetBool(\"cascade\")\nif !cascade {\n\t// pre-flight: list bound agents and rebind before deleting\n\t// GET /api/runtimes/<id>/agents -> rebind each -> then delete\n}","typeGuard":null,"tryCatchPattern":"err = client.DeleteJSON(ctx, \"/api/runtimes/\"+runtimeID)\nif conflict, ok := runtimeDeleteConflict(err); ok {\n\tif !cascade {\n\t\t// decision point: rebind (safe) vs --cascade (unbind+delete, history kept)\n\t\treturn fmt.Errorf(\"active agents: %s; rebind or pass --cascade\", strings.Join(conflict.AgentDisplays(), \", \"))\n\t}\n}","preventionTips":["Rebind active agents before decommissioning a runtime; --cascade is the accepted fallback.","--cascade keeps agents and history — it only unbinds, but confirm that matches your intent.","Automate pre-delete checks: list bound agents and require an empty set (or explicit --cascade) in CI."],"tags":["go","cli","conflict","runtimes","agents","cascade","guard"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}