multica-ai/multica · error

update agent: %w

Error message

update agent: %w

What it means

Wrapped error returned when `multica agent update <id>` fails to PUT the changed-field body to `PUT /api/agents/{id}`. The %w carries the API client failure: unknown agent id (404), auth failure, connectivity loss, or server-side validation of the new field values.

Source

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

		}
		body["max_concurrent_tasks"] = v
	}
	if mc, ok, err := resolveMcpConfig(cmd); err != nil {
		return err
	} else if ok {
		body["mcp_config"] = mc
	}

	if len(body) == 0 {
		return fmt.Errorf("no fields to update; use --name, --description, --instructions, --runtime-id, --runtime-config, --model, --thinking-level, --service-tier, --custom-args, --mcp-config, --visibility, --status, or --max-concurrent-tasks (env vars now live behind `multica agent env set <id>`)")
	}

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

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

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

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

func runAgentArchive(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. Confirm the agent exists: `multica agent get <id>` (or list) — fix or re-copy the id
  2. If archived, restore first: `multica agent restore <id>`
  3. Check connectivity/auth (server running, MULTICA_API_URL and token valid)
  4. Act on the wrapped cause text — it names the rejected field for 400 responses

Example fix

# before
multica agent update agt_stale --status active
# Error: update agent: 404: agent not found

# after
multica agent list                 # find the current id
multica agent update agt_real --status active
Defensive patterns

Strategy: try-catch

Validate before calling

multica agent get "$AGENT_ID" >/dev/null 2>&1 || { echo 'agent id invalid or unreachable'; exit 1; }
multica agent update "$AGENT_ID" --name "$NAME"

Try / catch

if err := client.PutJSON(ctx, "/api/agents/"+id, body, &result); err != nil {
	return fmt.Errorf("update agent: %w", err) // inspect 404 vs 400 vs network
}

Prevention

When it happens

Trigger: `multica agent update <id> --name X` where <id> does not exist or is archived, the server is unreachable, the token is invalid, or the server rejects the new value (e.g. invalid model string or negative max-concurrent-tasks).

Common situations: Using an agent id from another workspace, agent was archived between listing and updating, expired session, or passing a value the CLI accepts but the server rejects.

Related errors


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