{"record":{"id":"63cae519c6034332","repo":"multica-ai/multica","slug":"restore-agent-w","errorCode":null,"errorMessage":"restore agent: %w","messagePattern":"restore agent: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":859,"sourceCode":"\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\tfmt.Printf(\"Agent archived: %s (%s)\\n\", strVal(result, \"name\"), strVal(result, \"id\"))\n\treturn nil\n}\n\nfunc runAgentRestore(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar result map[string]any\n\tif err := client.PostJSON(ctx, \"/api/agents/\"+args[0]+\"/restore\", nil, &result); err != nil {\n\t\treturn fmt.Errorf(\"restore agent: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\tfmt.Printf(\"Agent restored: %s (%s)\\n\", strVal(result, \"name\"), strVal(result, \"id\"))\n\treturn nil\n}\n\nfunc runAgentTasks(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L841-L877","documentation":"Wrapped error returned when `multica agent restore <id>` fails to POST to `/api/agents/{id}/restore`. Restore reverses archiving; the wrapped cause is typically 404 (unknown id), a state error (agent is not archived so there is nothing to restore), auth failure, or a network error.","triggerScenarios":"`multica agent restore <id>` on an agent that is already active, a deleted or mistyped id, or while the server is unreachable / the token is invalid.","commonSituations":"Running restore twice in a script; restoring an agent that was hard-deleted; id from an old workspace; expired credentials.","solutions":["Check the agent's state first: `multica agent get <id>` — if already active, no restore is needed","Correct or re-copy the agent id from `multica agent list`","Resolve connectivity/auth issues if the wrapped error indicates connection or 401/403","Re-run after correcting state or environment"],"exampleFix":"# before\nmultica agent restore agt_1   # agent already active\n# Error: restore agent: 400: agent is not archived\n\n# after\nmultica agent get agt_1   # status=active; proceed to use the agent","handlingStrategy":"try-catch","validationCode":"status=$(multica agent get \"$AGENT_ID\" --output json | jq -r .status)\n[ \"$status\" = \"archived\" ] && multica agent restore \"$AGENT_ID\" || echo 'agent not archived; nothing to restore'","typeGuard":null,"tryCatchPattern":"if err := runAgentRestore(cmd, args); err != nil {\n\tif strings.Contains(err.Error(), \"not archived\") { return nil }\n\treturn fmt.Errorf(\"restore agent: %w\", err)\n}","preventionTips":["Confirm the agent is actually archived before restoring","Run restore once per state transition in scripts, not in retry loops","Validate the agent id first with `agent get`"],"tags":["cli","api","lifecycle","agent"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}