MCPcopy Create free account
hub / github.com/astercloud/aster / validateAgentConfig

Method validateAgentConfig

pkg/config/loader.go:221–247  ·  view source on GitHub ↗

validateAgentConfig 验证 AgentConfig

(config *types.AgentConfig)

Source from the content-addressed store, hash-verified

219
220// validateAgentConfig 验证 AgentConfig
221func (l *Loader) validateAgentConfig(config *types.AgentConfig) error {
222 // 检查必需字段
223 if config.TemplateID == "" {
224 return errors.New("template_id is required")
225 }
226
227 // 检查是否有未展开的必需变量
228 if strings.Contains(fmt.Sprintf("%v", config), "__ERROR__:") {
229 return errors.New("config contains unexpanded required variables")
230 }
231
232 // 验证 ModelConfig
233 if config.ModelConfig != nil {
234 if err := l.validateModelConfig(config.ModelConfig); err != nil {
235 return fmt.Errorf("model_config: %w", err)
236 }
237 }
238
239 // 验证 Multitenancy
240 if config.Multitenancy != nil && config.Multitenancy.Enabled {
241 if config.Multitenancy.OrgID == "" && config.Multitenancy.TenantID == "" {
242 return errors.New("multitenancy enabled but neither org_id nor tenant_id specified")
243 }
244 }
245
246 return nil
247}
248
249// validateModelConfig 验证 ModelConfig
250func (l *Loader) validateModelConfig(config *types.ModelConfig) error {

Callers 2

TestValidateAgentConfigFunction · 0.95
LoadAgentConfigMethod · 0.95

Implementers 1

Managerpkg/memory/rules/manager.go

Calls 1

validateModelConfigMethod · 0.95

Tested by 1

TestValidateAgentConfigFunction · 0.76