multica-ai/multica · error

restore agent: %w

Error message

restore agent: %w

What it means

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.

Source

Thrown at server/cmd/multica/cmd_agent.go:859

		return cli.PrintJSON(os.Stdout, result)
	}

	fmt.Printf("Agent archived: %s (%s)\n", strVal(result, "name"), strVal(result, "id"))
	return nil
}

func runAgentRestore(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}

	ctx, cancel := cli.APIContext(context.Background())
	defer cancel()

	var result map[string]any
	if err := client.PostJSON(ctx, "/api/agents/"+args[0]+"/restore", nil, &result); err != nil {
		return fmt.Errorf("restore agent: %w", err)
	}

	output, _ := cmd.Flags().GetString("output")
	if output == "json" {
		return cli.PrintJSON(os.Stdout, result)
	}

	fmt.Printf("Agent restored: %s (%s)\n", strVal(result, "name"), strVal(result, "id"))
	return nil
}

func runAgentTasks(cmd *cobra.Command, args []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}

	ctx, cancel := cli.APIContext(context.Background())

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. Check the agent's state first: `multica agent get <id>` — if already active, no restore is needed
  2. Correct or re-copy the agent id from `multica agent list`
  3. Resolve connectivity/auth issues if the wrapped error indicates connection or 401/403
  4. Re-run after correcting state or environment

Example fix

# before
multica agent restore agt_1   # agent already active
# Error: restore agent: 400: agent is not archived

# after
multica agent get agt_1   # status=active; proceed to use the agent
Defensive patterns

Strategy: try-catch

Validate before calling

status=$(multica agent get "$AGENT_ID" --output json | jq -r .status)
[ "$status" = "archived" ] && multica agent restore "$AGENT_ID" || echo 'agent not archived; nothing to restore'

Try / catch

if err := runAgentRestore(cmd, args); err != nil {
	if strings.Contains(err.Error(), "not archived") { return nil }
	return fmt.Errorf("restore agent: %w", err)
}

Prevention

When it happens

Trigger: `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.

Common situations: Running restore twice in a script; restoring an agent that was hard-deleted; id from an old workspace; expired credentials.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/63cae519c6034332. Report an issue: GitHub.