Before working with variants, ensure your graph is properly configured for experimentation:
Copy
// CRITICAL: Enable remote config in your graph codeconst graph = new GraphBuilder({ id: 'my-graph-id', // Must match CLI deployment apiKey: process.env.INWORLD_API_KEY, enableRemoteConfig: true, // Required for Portal experiments}) .addNode(llmNode) .setStartNode(llmNode) .setEndNode(llmNode) .build();
Without enableRemoteConfig: true, your deployed graph will ignore Portal-configured variants and always use local configuration, making A/B testing impossible.
Note: Traffic distribution and variant activation are managed through the Inworld Portal web interface, not through CLI commands. The CLI is used for registering and listing variants, while traffic management happens in the portal.
For experiments to work correctly, you must pass UserContext with unique targeting keys. The CLI’s advanced input format supports this:
Copy
# CORRECT: Include UserContext for proper A/B testinginworld run ./graph.ts '{ "input": {"message": "Hello"}, "userContext": { "targetingKey": "user123", "attributes": { "country": "US", "tier": "premium", "app_version": "2.1.0" } }}'
Common Mistake: Without unique targeting keys, all users get the same variant regardless of your Portal traffic splits. Always include userContext.targetingKey with a unique user identifier.
Calculate sample size upfront - Use Power Analysis calculator with baseline metrics, desired MDE (typically 2-5%), α = 0.05, and power = 0.80
Create variants with consistent naming - Use naming conventions like model-prompt-tools (e.g., “GPT5-Creative-Memory” vs “Claude4Sonnet-Analytical-RAG”)
Always pass UserContext with targeting keys - Use unique user IDs as targeting keys to ensure consistent variant assignment
Running Phase:
Start with small traffic allocation - Use 10-20% traffic to validate setup, then scale to reach calculated sample size
Use rule ordering strategically - Put specific targeting rules (premium users, specific regions) at the top since rules evaluate top-to-bottom
Setup or basic CLI issues? See the CLI Troubleshooting Guide for common problems.Experiment problems? Check the CLI Troubleshooting Guide for A/B testing and variant-specific issues.Your variant system is now ready for sophisticated A/B testing and continuous optimization of your AI graphs!