Skip to content

[FSSDK-11587] Implement CMAB config #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Mat001
Copy link
Contributor

@Mat001 Mat001 commented Jun 20, 2025

Added CMAB (Contextual Multi-Armed Bandit) support to Agent

  1. CMAB Configuration Integration:
    - Added structured CMABConfig, CMABCacheConfig, and CMABRetryConfig types to config package
    - Implemented JSON-based configuration via OPTIMIZELY_CMAB environment variable
    - Added support for partial configuration via OPTIMIZELY_CMAB_CACHE and OPTIMIZELY_CMAB_RETRYCONFIG
    - Configuration includes request timeouts, cache settings (type, size, TTL), and retry logic with exponential backoff
  2. go-sdk Integration:
    - Updated Agent to use go-sdk v2.1.1 with CMAB support
    - Modified defaultLoader() to create go-sdk clients with CMAB service when configured
    - Agent passes CMAB configuration to go-sdk's WithCmabService() factory option
    - Leverages go-sdk's core CMAB service, caching, and decision integration
  3. Client Factory Integration:
    - Added CMAB configuration parsing and validation in client creation pipeline
    - Integrated with existing Agent client caching mechanism
  4. HTTP Endpoint Enhancement:
    - Enhanced /decide endpoint to return CMAB predictions alongside feature flag decisions
    - No API changes required - CMAB data is included in existing response format when available
    - Agent serves enriched responses from go-sdk's enhanced Decide() method
  5. Configuration Refactoring:
    - Refactored from unstructured map[string]interface{} to structured types for better type safety
    - Updated all tests to use structured configuration types
    - Added comprehensive test coverage for various configuration scenarios
  6. Documentation & Testing:
    - Updated configuration examples and documentation
    - Added debug logging for troubleshooting CMAB configuration issues

Issues

FSSDK-11587

@Mat001 Mat001 self-assigned this Jun 20, 2025
@Mat001 Mat001 requested review from jaeopt and raju-opti June 20, 2025 18:51
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions about the config contexts and need your help to catch up.

@Mat001 Mat001 requested a review from jaeopt June 20, 2025 22:30
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good as is. I'd like to see how we use these configs (cache configs, especially) with go-sdks core.

@Mat001 Mat001 requested a review from jaeopt July 25, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants