Skip to content

feat: Configuration System Migration for Go (Ticket 1.2)#20

Open
devin-ai-integration[bot] wants to merge 6 commits intodemo-go-migrationfrom
devin/1760316239-config-system-migration
Open

feat: Configuration System Migration for Go (Ticket 1.2)#20
devin-ai-integration[bot] wants to merge 6 commits intodemo-go-migrationfrom
devin/1760316239-config-system-migration

Conversation

@devin-ai-integration
Copy link

Description

This PR implements Ticket 1.2: Configuration System Migration for the Go migration of Teal Agents. It converts the Python Pydantic-based YAML configuration and environment variable handling system to Go, maintaining full backward compatibility with all existing configuration files.

Link to Devin run: https://app.devin.ai/sessions/5f271213c82c46f4900bd7fa6dc3f441
Requested by: @jpartovi

Changes

Dependencies

  • Added github.com/spf13/viper for YAML parsing and environment variable binding
  • Added github.com/go-playground/validator/v10 for struct validation
  • Added gopkg.in/yaml.v3 for YAML unmarshaling
  • Added github.com/stretchr/testify for testing utilities
  • Go version upgraded from 1.21 to 1.24 (automatic upgrade to meet Viper requirements)

Type Definitions (pkg/config/types/)

  • common.go: Enums for ModelType, ContentType, SseEventType, TaskStatus, Role
  • models.go: Data models (UserMessage, AgentTask, TealAgentsResponse, etc.) converted from Python Pydantic models
  • config.go: Configuration structs for all orchestrator types (Sequential, Chat, Team, Planning, Assistant) with validation tags
  • env_config.go: Environment variable configuration with 24+ vars and default values matching Python implementation

Configuration Loader (pkg/config/loader/)

  • loader.go: Viper-based configuration loader with:
    • Environment variable binding with TA_ prefix
    • JSON-encoded env var store support (TA_ENV_STORE, TA_ENV_GLOBAL_STORE)
    • Auto-detection of config type by kind field
    • Type-specific loading methods for each orchestrator
    • Comprehensive validation using go-playground/validator

Tests (pkg/config/loader/tests/)

  • Unit tests: Environment variable loading, YAML parsing, validation constraints
  • Integration tests: Backward compatibility verification with 5 real config files from repository:
    • Getting Started Sequential
    • Chat with Plugins
    • Team Orchestrator
    • Planning Orchestrator
    • Assistant Orchestrator
  • All tests passing (10/10 unit + integration tests)

Build System

  • Added Makefile targets: go-test-config and go-test-integration
  • Added comprehensive README with usage examples and documentation

Type of Change

  • New feature
  • Documentation

Key Implementation Details

Type Mapping Strategy

  • Python Optional[T] → Go *T (pointer for optional fields)
  • Python Literal["a", "b"] → Go custom type with const values
  • Pydantic Field(ge=0, le=1)validate:"gte=0,lte=1"
  • Complex types like ChatHistory use any for flexibility

Environment Variable Handling

  • Viper prefix set to "TA" in NewConfigLoader()
  • Mapstructure tags use field names without TA_ prefix (e.g., mapstructure:"API_KEY")
  • Viper automatically adds prefix, so TA_API_KEY env var maps to API_KEY field

Backward Compatibility

All 5 integration tests passed, confirming that existing YAML files load correctly without modification.

Important Review Points

CRITICAL: Please verify the following:

  1. Type mappings: Cross-reference Go structs in pkg/config/types/*.go against Python Pydantic models in:

    • src/sk-agents/src/sk_agents/tealagents/models.py
    • src/sk-agents/src/sk_agents/ska_types.py
    • src/sk-agents/src/sk_agents/configs.py
  2. Environment variable handling: Test that TA_API_KEY and other env vars are correctly loaded with the Viper prefix configuration

  3. Validation constraints: Verify validation tags (especially Temperature field with validate:"omitempty,gte=0,lte=1")

  4. Default values: Confirm DefaultEnvConfig() matches Python ConfigManager.load() defaults

  5. Manual testing: Try loading a real YAML config file using the new Go loader to verify integration tests are accurate

  6. Go version: Deployment environments must support Go 1.24+ (auto-upgraded from 1.21)

Testing

All tests pass:

make go-test-config                # Unit tests: 8/8 passed
make go-test-integration           # Integration tests: 5/5 passed

The integration tests verify backward compatibility by loading actual config files from:

  • src/sk-agents/docs/demos/01_getting_started/config.yaml
  • src/sk-agents/docs/demos/10_chat_plugins/config.yaml
  • src/orchestrators/collab-orchestrator/orchestrator/conf/config_team.yaml
  • src/orchestrators/collab-orchestrator/orchestrator/conf/config_planning.yaml
  • src/orchestrators/assistant-orchestrator/orchestrator/conf/config.yaml

devin-ai-integration bot and others added 6 commits October 13, 2025 01:04
- Add github.com/spf13/viper for YAML parsing and env var binding
- Add github.com/go-playground/validator/v10 for struct validation
- Add gopkg.in/yaml.v3 for YAML unmarshaling
- Add github.com/stretchr/testify for testing utilities
- Go automatically upgraded from 1.21 to 1.24 to meet Viper requirements

Co-Authored-By: Jude Partovi <jude@partovi.org>
- Convert all models from models.py, ska_types.py, and config files
- Add common.go with enums (ModelType, ContentType, SseEventType, TaskStatus, Role)
- Add models.go with data models (UserMessage, AgentTask, TealAgentsResponse, etc.)
- Add config.go with all configuration types for each orchestrator
- Add env_config.go with environment variable configuration (24+ vars)
- Add validation tags for field constraints (temperature 0-1, required fields, etc.)
- Support all orchestrator types (Sequential, Chat, Team, Planning, Assistant)
- Maintain backward compatibility with Python structures

Co-Authored-By: Jude Partovi <jude@partovi.org>
- Use Viper for YAML parsing and env var binding with TA_ prefix
- Support all orchestrator types (Sequential, Chat, Team, Planning, Assistant)
- Implement TA_ENV_STORE and TA_ENV_GLOBAL_STORE JSON parsing
- Add comprehensive validation using go-playground/validator
- Ensure backward compatibility with existing YAML files
- Auto-detect config type by 'kind' field for flexible loading
- Properly handle optional fields with pointer types

Co-Authored-By: Jude Partovi <jude@partovi.org>
- Unit tests for env var loading with defaults and JSON stores
- Unit tests for YAML parsing (Sequential, Chat, TeamOrchestrator)
- Validation tests for field constraints (e.g., temperature range)
- Integration tests with 5 real config files from repository:
  * Getting Started Sequential
  * Chat with Plugins
  * Team Orchestrator
  * Planning Orchestrator
  * Assistant Orchestrator
- Test LoadConfigByKind auto-detection functionality
- All tests pass, confirming backward compatibility

Co-Authored-By: Jude Partovi <jude@partovi.org>
- Document features (Viper, validation, orchestrator support)
- Provide usage examples for env vars and YAML loading
- List all required environment variables
- Include testing commands for unit and integration tests

Co-Authored-By: Jude Partovi <jude@partovi.org>
- Add go-test-config for unit tests
- Add go-test-integration for integration tests with real configs

Co-Authored-By: Jude Partovi <jude@partovi.org>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants