Hey! I am trying to integrate our existing custom ...
# experimentation
f
Hey! I am trying to integrate our existing custom MultiArmBandit and update weights each N time via API https://docs.growthbook.io/api/#tag/experiments/operation/updateExperiment So, the problem is that new weights are simply ignored and is always 50/50 Is it a known issue? please see request/response in attached snippet
👀 1
1
For anyone looking for the same answer After checking the source code https://github.com/growthbook/growthbook/blob/main/packages/back-end/src/services/experiments.ts I noticed that the actual weight values are getting from another field
Copy code
if (reweight) {
  // apply the latest weights (SDK level)
  changes.phases[phase].variationWeights = banditResult.updatedWeights;
  // re-randomize to reduce bias (in cases of multiple exposures / failed sticky bucketing)
  changes.phases[phase].seed = uuidv4();
}
So the correct request would be to add separate
variationWeights
Copy code
{
  "phases": [
    {
      "name": "MAB Optimization 2025-01-27T12:46:43Z",
      "dateStarted": "2025-01-27T12:46:43Z",
      "trafficSplit": [
        {
          "variationId": "var_404rwz1tm6f1iccp",
          "weight": 0.4
        },
        {
          "variationId": "var_404rwz1tm6f1iccq",
          "weight": 0.6
        }
      ],
      "coverage": 1,
      "reason": "Multiarm Bandit Optimization",
      "seed": "seed_2025-01-27T12:46:43Z",
      "targetingCondition": "{}",
      "savedGroupTargeting": [],
      "variationWeights": [
        0.4,
        0.6
      ]
    }
  ],
  "status": "running"
}"}
h
Glad you were able to resolve it! Sorry there is some tech debt in this part of the code base that can make the API a little confusing. You're correct that you need to set the weights in the latest phase.
🙏 1