Introduction

The balance between immune defence and reproduction spans the animal kingdom and is influenced by various factors including life history, environment and evolutionary pressures1. In many species, the challenge of allocating limited resources to either immune responses against pathogens or reproduction is a common thread, governed by a delicate balance2,3,4. The diversity in immune responses among species, influencing disease susceptibility and overall fitness, is understood to stem from early-life events shaping immune development and responsiveness trajectories5,6. Early-life immune expression profiles in natural population of field voles (Microtus agrestis) persist into adulthood, significantly impacting disease susceptibility and overall fitness variability7, and early-life immunological cues in the house wren (Troglodytes aedon) predict longevity and lifetime reproductive success in the wild8. In insects, exposure to parasites can have lasting effects on immune gene expression across different life stages, potentially influencing the evolution of metamorphosis and immune defences9.

Insects are often known for their high reproductive capacity and rapid population growth10,11. Their success (in terms of abundance and diversity) on earth stems in large part from their ability to reproduce quickly and exploit available resources. Due to limited resources and time, organisms in general often face trade-offs in trait investment12. Within this context, juveniles may prioritize growth over immune defence, possibly delaying investment in immunity until later in life when growth is less critical. This allocation of resources may result in a trade-off between juvenile susceptibility and growth rate or future reproductive success. Consistent with this, insects may prioritize current reproduction over future opportunities as they near the end of their life (i.e. the terminal investment hypothesis)13,14, and trade this investment in reproduction off with other traits like immunity15,16. One reason for this differential investment is the short lifespan of most insects17, as they have evolved to prioritize producing as many offspring as possible within their limited lifespan. In these cases, immune defences may be relatively downplayed, as these organisms rely on a high reproductive rate to compensate for potential losses due to pathogens4,18. This does not mean that insects completely neglect immune defence19,20. Evolutionary pressures and natural selection act on their immune system such that they do have a certain level of protection against diseases19,21. In a favourable environment with abundant resources and low pathogen pressure, insects may allocate more resources towards reproduction22,23. Conversely, in environments with greater pathogen pressure, such as in crowded populations or with exposure to disease-causing organisms, there may be a greater investment in immune defences (e.g. density-dependent prophylaxis hypothesis-DDP)21,24,25.

This adaptive allocation is often facilitated by phenotypic plasticity, the ability to alter physical and behavioural traits in response to environmental cues. Population density is an important environmental cue that influences resource availability, competition and social interactions26,27. Higher population densities can trigger alterations in cuticle colour towards melanization, increased midgut epithelium and peritrophic matrix thickness, gregarious behaviour and altered hormone levels28,29,30. Experimental manipulation of population density and examination of the resulting phenotypic responses can help to understand how organisms adapt and adjust their traits in different ecological contexts, providing insights into the mechanisms underlying phenotypic plasticity31,32.

Studying the factors influencing resource allocation in insects for reproduction and immune defence contributes to understanding the ecological and evolutionary outcomes of these choices. In the case of the velvetbean caterpillar Anticarsia gemmatalis (Lepidoptera: Erebidae), changes in population density can lead to phenotypic plasticity31,33, including investment in immunity30,32,34. Thus, investment in immunity during the larval stage might affect the susceptibility of adults and their offspring to pathogens and parasites35,36. This highlights the importance of understanding how changes in population density can impact not only the immediate survival and fitness of A. gemmatalis larvae, but also their reproductive success as adults. The insect’s haemolymph and its eggs contain various immune factors which work to defend against invading pathogens37, and thus help to enhance the insect’s survival and reproductive output. Here we use A. gemmatalis as a model to understand the phenomenon, in part as it is an agricultural pest controlled by pathogens like Anticarsia gemmatalis multiple nucleopolyhedrovirus (AgMNPV) and Bacillus thuringiensis (Bt). Understanding its immune responses can inform pest control strategies involving these pathogens.

To evaluate the costs and benefits of immune investment in insects, a comprehensive approach is needed. Factors such as resource allocation trade-offs, population density effects on immune system activation, and carry-over effects of larval immunity on adult processes must be considered4,31. By comparing individuals that have experienced different population densities, it may be possible to observe variations in immune defences and reproductive traits38,39. For insects, longitudinal studies that track larval immune investment and subsequent adult reproductive success can help establish the link between these two processes, and shed light on the adaptive strategies that shape their survival and reproduction in changing environments.

We aimed here to investigate how population density and immunological challenge during the larval stage might affect immune investment carried through into this and subsequent life stages, and reproductive outcomes in adult A. gemmatalis. We hypothesize that due to their short lifespan, insects prioritize reproduction over immune defence, resulting in relatively downplayed immune responses. However, under conditions of high population density or bacterial challenges, these insects may exhibit enhanced immune responses during the larval stage. This increased early-life immune investment may come at a cost to reproductive parameters later in life. Therefore, we predict that (i) individuals reared at high population density or exposed to bacterial challenges during the larval stage will show more active immune responses in the larval stage, (ii) this heightened immune response will persist into the prepupal stage, and (iii) these stimuli will negatively affect reproductive parameters in adulthood, including moth weight, egg production, and lytic activity in eggs (see graphical illustration at Fig. 1).

Fig. 1
figure 1

The graphical illustration shows the experimental design used to investigate how population density and immunological challenges during the larval stage affect immune responses and developmental outcomes in Anticarsia gemmatalis moths. Two density treatments (high and low density) and three immune challenges (control—no challenge, physical puncture with a needle, and a puncture with a bacteria-contaminated needle) were applied during the larval stage in Experiments 1, 2, and 3. In Experiment 4, only the density treatment was applied without any immune challenge. Immune responses were measured at different developmental stages—larval, prepupal, and adult (eggs)—with a focus on lytic activity during the larval and prepupal stages, as well as reproductive parameters in adulthood. This setup was designed to explore how early-life conditions might influence immune and fitness-related traits later in life.

Materials and methods

Anticarsia gemmatalis

This study was conducted at the Laboratory of Insect-Microorganism Interactions, Department of Entomology, at the Universidade Federal de Viçosa (UFV) in Viçosa, Brazil. The A. gemmatalis colony at UFV originated from a stock colony from EMBRAPA/CNPSo and has been maintained under controlled environmental conditions. Larvae were reared at 27 ± 2 °C, with 50 ± 10% relative humidity and a 12-h photophase. Adult moths were maintained at a relative humidity of 70 ± 10% and a 14-h photophase. For oviposition, non-sexed moths (approximately 80) were housed in four wooden cages measuring 30 cm × 30 cm × 30 cm, with approximately 80 moths—from the same colony—per cage. The cages were lined internally with sheets of sulfite paper substrate. The moths were fed an artificial diet ad libitum: 10.5 g honey, 1.05 L distilled water, 350 mL beer, 60 g sucrose, 1.05 g ascorbic acid, and 1.05 g methylparaben40. Eggs laid by the moths on the sulfite paper were collected daily and transferred to 500 mL plastic pots where they were kept until hatching. Ecloded caterpillars were provided with an artificial diet ad libitum: 250 g bean, 200 g wheat germ, 200 g soy protein, 100 g casein, 150 g yeast, 12 g ascorbic acid, 300 mg tetracycline, 10 g methylparaben, 6 g sorbic acid, 75 g agar, 40 mL distilled water, 30 mL vitamin complex, and 12 mL formaldehyde 40%40. Four separate experiments were conducted. For the first three of these, twenty-five to forty caterpillars were used per treatment group, following a 2 × 3 factorial design with two density treatments and three immunological challenges. The fourth experiment had only the two density treatments.

Experiment 1: effects of population density and immunological challenge on lytic activity in caterpillar haemolymph

Anticarsia gemmatalis larvae change their phenotype (cuticular colour, thickness of midgut, behaviour and juvenile hormone titre) plastically in response to crowding30,31,32. To stimulate this, 180 newly hatched caterpillars were reared for 10 days, corresponding approximately to the 4th instar, under two different population density treatments, either (i) individually in separate pots representing a low population density, or (ii) with four caterpillars together in the same pot as a high population density known to trigger a change in phenotype32. Only one caterpillar, randomly chosen, from a given pot was ever assayed in this and following experiments, to avoid pseudoreplication32.

We aimed here to induce immune responses in 10 day-old caterpillars by subjecting them to different immunological challenges: (i) handled—caterpillars were subjected to gentle handling without any specific immune stimulus; this was a control group to assess the baseline immune response of the caterpillars without any external stimulus beyond handling, (ii) wounded—caterpillars were wounded using an entomological needle that had been immersed in sterile distilled water as a control stimulus to evaluate the caterpillars' response to a non-pathogenic or non-specific immune challenge, and (iii) bacteria challenged—caterpillars were wounded using an entomological needle that had been immersed in a suspension of lyophilized (and therefore dead) bacteria (Micrococcus lysodeikticus) cells from Sigma-Aldrich® ATCC No. 4698 to simulate the presence of bacteria in the haemocoel as might occur through natural wounding41. In treatments with wounding, only the tip of the needle was inserted into the dorsal thoracic region of the caterpillars to stimulate the caterpillars' immune system without causing the haemolymph to overflow.

Lytic activity is the ability of the immune system to lyse and so destroy bacterial cells. Proteins with lytic activity, such as lysozymes, are among the most extensively studied enzymes in antibacterial research42. Typically present at low, baseline levels, these enzymes are significantly upregulated following infection and play a crucial role in the lytic antibacterial response19. Given their importance in defence mechanisms, lytic activity serves as a critical immune parameter in our study, directly linked to the pathogen used and reflective of the insect’s immune response. To assess this, we prepared Petri dishes containing agar and dead bacteria (M. lysodeikticus) cells. Agar plates were prepared by combining 1.5% agar, 75 mg M. lysodeikticus cells, 100 mL distilled water, and 50 mL potassium phosphate buffer (2 M, pH 6.4). The bacteria act as a substrate for the caterpillar's immune system to exhibit its lytic activity. Twenty-four hours after immunological challenge (described above), haemolymph was collected through a small hole made between the first and second proleg of caterpillars using a sterile entomological needle. Haemolymph samples were collected using a pipette. In each agar plate, holes with a diameter of 1.5 mm were punched using glass capillary tubes, and each well was filled with 1 µL of haemolymph from caterpillars. Each sample was prepared in duplicate for technical replicates. The plates were then incubated at 33 °C for 24 h to allow any lytic activity to occur. After incubation, the diameters of the translucent zones around the samples on the agar plates were measured using a digital caliper. This serves as an indicator of the lytic activity present in the samples. Experimental setup and methodology were adapted from41,43.

Experiment 2: effects of larval population density and immunological challenge on lytic activity in prepupal haemolymph

Energetic reserves in the prepupal and pupal stages derive exclusively from the larval one as the insect no longer feeds. Therefore, immune defences activated during the larval stage could potentially result in trade-offs against reproduction. Analyzing immune responses in prepupal haemolymph may offer insights into potential trade-offs associated with reproductive investment. The experimental set-up was as in Experiment 1 with population density and wounding treatments, but caterpillars were reared—still at either low or high densities—until they reached the prepupal stage (i.e. sixth larval instar), at which point they ceased movement and feeding activities in preparation for pupation. As before, to avoid pseudoreplication and ensure that each individual used for analysis was independent, only one prepupa was randomly chosen from each pot. A total of 30 prepupae were included in each treatment group. Haemolymph was collected from the first dorsal thoracic segment of the prepupae and then added to holes in agar plates, as described above, to measure lytic activity.

Experiment 3: effects of population density and immunological challenge on pupal development

With the same set-up as in the previous experiments, caterpillars (thirty individuals per treatment) were allowed to progress from the prepupal to the pupal stage. Time to reach this stage (i.e. pupate) was recorded and individuals were weighed using a balance (accuracy = 0.001 g).

Experiment 4: relationship between population density, moth weight, egg numbers, and lytic activity in eggs

The main objective here was to examine the influence of larval population density on the fitness of adult moths (i.e. males and females). In preliminary tests, we were unable to extract haemolymph from adult moths so we could not challenge them immunologically and measure effects on the haemolymph. We still wished to examine effects of population density on adult traits, however. For this, newly hatched caterpillars were reared as above either in isolated or crowded conditions until they reached the pupal stage. From each pot, one 1-day-old pupa was randomly selected, weighed, sexed, and kept separate until it hatched into a moth. Sixty-five to seventy 1-day-old moths from each treatment group were housed in plastic cages and provided with artificial diet ad libitum (see above) for a period of 5 days. Afterwards, the moths were individually placed in 100 mL pots lined with sulfite paper to facilitate oviposition and egg collection. Fitness costs were measured by assessing: (i) the number of eggs laid by each female moth as an indicator of reproductive output, (ii) the lytic activity in the eggs (using 100 eggs taken at random from each female), which provides information about immune defence, and (iii) the moth's weight as an indicator of the potential fitness.

Statistical analyses

In experiments 1 and 2, conducted to investigate the effects of population density and immunological challenge (independent variables) on lytic activity (dependent variable) in caterpillars and prepupae, statistical analyses were performed using generalized linear models (GLMs) with a normal distribution. Full models were fitted, including the population density × immunological challenge interaction, and subsequent simplification was done by removing nonsignificant terms. The final models were accepted if they were not significantly different from the previous models. Residuals of the final models were checked to ensure the suitability of the distribution.

For experiments 3 and 4, which involved multiple dependent variables (e.g. time to pupate and pupal weight in experiment 3, and number of eggs, lytic activity in the eggs, and weights of male and female moths in experiment 4), a multivariate analysis of variance (manova) was used. This analysis takes into account the covariance among the dependent variables and possible interactions within the model. The statistical significance of the independent variables (population density and immunological challenge) on the dependent variables measured from prepupae and moths was assessed using the multivariate measures Pillai's trace, Wilks' lambda, Hotelling-Lawley trace, and Roy's largest root. All of these multivariate measures produced similar results, so Pillai's trace was chosen as the most robust against Type I error44. If manova results were found to be significant, post-hoc univariate analyses of variance (anovas) were performed. Pearson's product-moment correlation tests were used to examine the relationships between dependent variables.

For all experiments, post-hoc Tukey's honest significant difference (HSD) tests were conducted to compare the factor levels of the immunological challenge treatment with a 95% family-wise confidence level.

All statistical analyses were conducted using R version 4.4.045.

Results

Experiment 1: effects of population density and immunological challenge on lytic activity in caterpillar haemolymph

The lytic activity of the haemolymph of caterpillars was measured as the diameters of translucent zones in the agar plates (see above). There was no interaction between effects of population density and immune challenge (F2,173 = 0.126, P = 0.881) on the lytic activity of the caterpillars’ haemolymph (Fig. 2a). Lytic activity was 6.6% greater in the high density treatment compared with the low density treatment (F1,177 = 4.84, P = 0.029). Immune challenge also affected lytic activity in the haemolymph of caterpillars (F2,175 = 44.36, P < 0.001), such that bacteria challenged caterpillars had 33% higher activity (Tukey's HSD test, P < 0.001) than both groups of handled and wounded caterpillars, with no difference between these two groups (P > 0.05) (Fig. 2a).

Fig. 2
figure 2

Lytic activity in Anticarsia gemmatalis (a) caterpillar and (b) prepupae haemolymph in relation to immunological challenges (handling, wounding with a clean needle, or wounding with a needle immersed in a bacteria suspension) and population density conditions (low density—one caterpillar per pot, and high density—four caterpillars per pot). Two-way anova was performed to analyse the data, followed by post-hoc Tukey's HSD test for comparisons. Open circles represent the raw data for low density conditions, while filled circles represent the data for high density conditions. The error bars depict the standard error of the mean. Asterisks (* or ***) representing a significant difference between population density conditions and immunological challenges at P < 0.05 or P < 0.01, respectively.

Experiment 2: effects of population density and immunological challenge on lytic activity in prepupal haemolymph

There was no interaction effect between the population density condition and immunological challenge on the lytic activity in the haemolymph of prepupae (F2,174 = 0.291, P = 0.747). Lytic activity in the haemolymph of prepupae did not vary with the population density of caterpillars (F1,178 = 0.280, P = 0.597) (Fig. 2b) or immunological challenge (F2,176 = 0.43, P = 0.648) (Fig. 1b).

Experiment 3: effects of population density and immunological challenge on pupal development

There were no interactions between population density and immune challenge in effects on prepupal weight or time to pupation (two-way manova: Pillai’s trace = 0.014, approximate F2,114 = 0.415, P = 0.797). Population density had a significant overall impact on both prepupal weight and time to pupation (two-way manova: Pillai’s trace = 0.772, approximate F1,114 = 192.110, P < 0.001) (Fig. 3a,b), while immune challenge had no effect on either dependent variable (two-way manova: Pillai’s trace = 0.046, approximate F2,114 = 1.355, P = 0.250) (Fig. 3a,b). A post-hoc Tukey’s HSD test was used to further analyse the differences between specific environmental factors. Specifically, prepupae reared at low density were on average 13% heavier than those reared at high density. Similarly, caterpillars reared at low density took an average of 6% longer to pupate than those reared at high density. Prepupal weight and time to pupation were positively correlated (correlation coefficient = 0.485, P < 0.001), indicating that heavier prepupae were associated with longer development times.

Fig. 3
figure 3

Mean (a) prepupae weight of Anticarsia gemmatalis and (b) number of days to pupation in relation to immunological challenges (handling, wounding with a clean needle, or wounding with a needle immersed in a bacteria suspension) and population density conditions (low density—one caterpillar per pot, and high density—four caterpillars per pot). Two-way manova was performed to analyse the data, followed by post-hoc Tukey's HSD test for comparisons. Open circles represent the raw data for low density conditions, while filled circles represent the data for high density conditions. The error bars depict the standard error of the mean. Asterisks (***) representing a significant difference between population density conditions at P < 0.01.

Experiment 4: relationship between population density, moth's weight, egg numbers, and lytic activity in eggs

For females, larval population density had a significant overall impact on adult and egg phenotypic traits (i.e. adult weight, egg numbers and lytic activity in the eggs; two-way manova: Pillai’s trace = 0.405, approximate F1,131 = 29.367, P < 0.001), while there was no effect of larval population density on these traits in males (Pillai’s trace = 0.013, approximate F1,131 = 0.575, P = 0.632) and no interaction between female and male population densities (Pillai’s trace = 0.028, approximate F1,131 = 1.266, P = 0.288) (Fig. 4a–c).

Fig. 4
figure 4

(a) Mean lytic activity in eggs, (b) adult weight and (c) number of eggs per female of Anticarsia gemmatalis as a function of population density conditions (low density—one caterpillar per pot, and high density—four caterpillars per pot) in which larvae were raised. The statistical analysis was performed using two-way manova, and post-hoc Tukey's HSD test for comparisons; asterisks (***) connote a significant difference between population density conditions at P < 0.01. Open and filled circles represent the raw data for females and males, respectively, and the error bars depict the standard error of the mean.

To further explore the significant effect of population density on females, univariate anovas were conducted for each phenotypic trait. Female moths reared at low density were on average 13% heavier than to those reared at high density conditions (F1, 131 = 65.1394, P < 0.001), however population density did not affect the number of eggs (F1, 131 = 0.6973, P = 0.4052) or lytic activity in the eggs (F1, 131 = 0.864, P = 0.354) (Fig. 4a–c). Pairwise correlation analysis showed a significant negative correlation between the number of eggs and lytic activity in the eggs (r = − 0.175, P = 0.042) as well as between adult weight and the number of eggs (r = − 0.264, P = 0.002). However, no significant correlation was found between lytic activity in the eggs and adult weight (r = − 0.006, P = 0.949).

Discussion

The primary focus was on whether immune defences, triggered in the larval stage by population density and immunological challenge, persist into subsequent life stages. The species we used, A. gemmatalis, plastically adjusts phenotypic traits to environmental cues30,31,32,33,34. Our primary finding is that immune defences are heightened immediately after these stimuli in the larval stage but the effects do not persist into subsequent prepupal and adult stages, possibly because the rapid utilization of the immune factors, and does not replenish it fast enough to maintain elevated levels across developmental stages. This finding is in stark contrast to findings from vertebrates such as voles and birds7,8, and insects like the field cricket Gryllus campestris whose immune stimuli during juvenile stages elevates levels of immune parameters in adulthood46, the red flour beetle Tribolium castaneum whose early-life exposure to parasites can have lasting effects on immune gene expression across different life stages9 and Anopheles gambiae in which adults previously infected as larvae have enhanced bacterial clearance efficiency in the haemocoel and additionally display higher haemocyte counts when compared to those originated from naive or injured larvae47. While the cited studies involved more invasive or direct infection methods, our aim was to explore whether early-life conditions, such as high population density and mild immune challenges, could have lasting effects on immune parameters and fitness traits in adulthood. Although the methods differ, our study demonstrates that even these relatively mild early-life challenges can influence later-life outcomes, contributing valuable insights into the broader concept of how juvenile experiences shape adult phenotypes. This discrepancy challenges our hypotheses, as these were constructed upon previous empirical evidence.

Our first hypothesis was that individuals reared at a high population density and / or subjected to a bacterial immune challenge during the larval stage would have more active immune responses while still in this juvenile stage. This response in the caterpillars is expected, based on previous work, and serve as the baseline, to see if the effect is carried through beyond the larval stage. We observed that A. gemmatalis caterpillars reared at high population densities exhibited higher lytic activity in their haemolymph compared to those reared at low densities. This finding is consistent with previous studies on this32,34 and other insect species39,48, which have demonstrated increased immune investment in response to higher population density, including higher lytic activity49. According to the DDP hypothesis (see Introduction), high population density is a signal that triggers heightened immune responses as an adaptive strategy to reduce the risk of pathogen transmission and disease spread24,25. Additionally, we found that non-specific injury (i.e. wounded), particularly more severe ones such as piercing with a potential pathogenic threats (i.e. bacteria challenged), trigger a more robust immune response increasing the lytic activity in the caterpillar's haemolymph, indicating that the immune system of A. gemmatalis is capable of recognizing and responding to various immune stimuli. The primary barriers (e.g. cuticle and peritrophic matrix) in invertebrates act as the first line of defence against parasites and pathogens30,50. Yet, wounds can serve as entry points for these invaders. Frequent wounding may increase immune challenges, affecting immune function. Wounds are common in natural populations of the fruit fly Drosophila melanogaster, suggesting selection pressure on host immunity favouring traits that enable rapid and effective wound repair, as well as prompt responses to opportunistic infections51. This aligns with studies in other insects, the wax moth Galleria mellonella and the mealworm beetle Tenebrio molitor, which have reported the activation of immune responses following wounding52,53. Additionally, Johnston and Rolff54 demonstrated that wounds inflicted by bacteria-inoculated needles elicited stronger immune responses in the damselfly Coenagrion puella, compared to wounds from clean needles. However, in the amphipod Gammarus pulex, high wound abundance correlates negatively with PhenolOxidase activity55.

The second hypothesis was that immune defence activation during the larval stage would persist into the prepupal stage, potentially leading to trade-offs in development or reproduction. However, our findings did not support this: lytic activity in the haemolymph of prepupae was not influenced by population density or bacterial immune challenge during the larval stage. It is possible that there is a developmental difference in immune regulation, where the immune system of prepupae remains relatively stable and unaffected by previously population density56, at least within the range tested in this study. Additionally, the immune challenge applied during the larval stage had no persistent effects on the lytic activity in the prepupae's haemolymph nor did it affect the developmental parameters. Contrary to expectations, manipulating immunological investment through handling or wounding did not lead to discernible differences in development time or pupal weight. In the wax moth Galleria mellonella, immune challenge during metamorphosis did not affect the strength of the antibacterial immune response in subsequent developmental stages57. Rather, the immune response is likely transient and fades as the immune cells, such as haemocytes, efficiently clear the pathogens from the haemolymph with the immune response returning to a basal state once the stimulus is removed58. It is worth noting that the presence of microbiota and gut tissues from larvae may stimulate the pupa's immune system, such as the production of lysozyme and antibacterial factors, during metamorphosis59. This could contribute to the basal or upregulated state of the immune system observed in prepupae, regardless of population conditions and wound stimuli. However, in two forest caterpillars, Euclea delphinii and Lithacodes fasciola, late instars injected with bacteria exhibited a greater immune response, specifically an increased density of haemocytes, compared to early instars60. This suggests the presence of developmental immunity, where the immune response varies depending on the developmental stage.

Proceeding to examine the impacts on developmental parameters, population density affected both the time to pupation and pupal weight. Caterpillars reared at low densities exhibited longer development times and higher pupal weights compared to those reared at high densities. Indeed, crowding or high population density has been recognized as a significant factor influencing various life history traits in this33,34 and other insect species61,62. Developmental conditions experienced during the larval stage can have long-lasting effects on adult feeding behaviour. Crowded larval environments often result in resource competition and limited access to nutrients and as a result, individuals may undergo physiological and behavioural adaptations to cope with these conditions27. In a study on the polyphagous fruit fly Bactrocera tryoni, adults from the crowded larval treatment consumed, in a sex-specific manner, more food relative to their body weight compared to adults from the uncrowded treatment63. Resource competition and food deprivation can create selective pressures that favour individuals able to accelerate development and transition to the next life stage, such as adulthood64,65. By reaching adulthood earlier, they can potentially migrate or disperse to new environments where resources are less scarce or more suitable for their survival and reproduction66. In the tropical fig borer Batocera rufomaculata, adults that emerged from deteriorating hosts exhibited smaller body size compared to those emerging from their natural host, but despite this, smaller adults had proportionally larger flight muscles, providing them with a significant advantage in terms of flight endurance67. Understanding the effects of crowding on development and body size can provide insights into the adaptive strategies employed by insects in response to changing environmental factors.

Our third hypothesis was that high larval population density would affect adult reproductive parameters, including moth weight and egg production, and lytic activity in eggs. Despite the expectation that elevated population density might trigger DDP and subsequently enhance lytic activity in eggs, our findings reveal no apparent influence on this parameter. This suggests that, at least in the specific context of lytic activity, the anticipated impact of increased population density did not manifest. This corresponds with the results of Kelly and L’Heureux68, who similarly found no effect of rearing density on immunity in females of the sand cricket Gryllus firmus, but did observe density effects in two reproductive traits. However, in our study, reproductive output remained unaffected by sex or population density during the larval stage. This contradicts theory related to parental investment that predicts that females should invest more in their progeny than males12,69. However, it is important to recognize that investment strategies can vary among populations and species70. For instance, in the red flour beetle, immune-challenged parents invest equally in offspring immunity71, while T. molitor exhibits different strategies of immune investment for offspring72.

The study provides new insights into how environmental factors during the larval stage, such as population density and immunological challenges, influence immune responses and developmental outcomes in A. gemmatalis moths. Contrary to findings in some vertebrates and other invertebrates7,8,9,46,47, we found out that while these environmental factors increase lytic activity in caterpillars, this heightened immune response does not persist into later life stages. Although our methods differ from those used in studies of vertebrates and other invertebrates, the concept that early-life conditions shape later-life outcomes remains consistent. This aligns with broader research demonstrating that early environmental conditions can influence adult phenotypes across various taxa. Trade-offs, like delayed pupation and reduced prepupal weights under high density, suggest a balance between immune investment and development. This transient immune response suggests that holometabolous insects, like A. gemmatalis, may prioritize immediate survival over long-term immune investment, balancing immune defence with developmental needs. Holometabolous insects demonstrate phenotypic plasticity and evolutionary adaptation through distinct life stages. Complete metamorphosis creates specialized forms for each stage, challenging the predictability of the larval environment for the adult. Potential epigenetic effects and rapid environmental changes for caterpillars also pose challenges. Long-term studies on immune investment and population dynamics in insects are crucial for predicting responses to environmental changes. The implications of our study offer potential applications in pest management of this and other agricultural pests by revealing how environmental pressures can shape the life history traits. Future research should focus on long-term studies of immune investment and reproductive success across different environmental conditions, as well as comparisons with hemimetabolous insects, to further unravel the evolutionary dynamics of immune strategies in changing environments.