Centralize pure pipeline profile and binding copies

This commit is contained in:
2026-11-26 02:29:52 +00:00
parent 383b43ab08
commit ad357db22d
17 changed files with 271 additions and 257 deletions

View File

@@ -205,7 +205,7 @@ func documentBindingToRuntime(document BindingDocument) pipeline.ModuleBinding {
MaxAdditionalTurns: cloneValue(document.MaxAdditionalTurns),
Cache: cloneValue(document.Cache),
Module: document.Module,
Options: documentOptions(document.Options),
Options: pipeline.CloneModuleOptions(document.Options),
References: documentReferencesToRuntime(document.References),
}
if document.LLMProfile != nil {
@@ -224,7 +224,7 @@ func documentBindingToRuntime(document BindingDocument) pipeline.ModuleBinding {
func documentValidatorToRuntime(document ValidatorDocument) pipeline.ModuleBinding {
binding := pipeline.ModuleBinding{
Module: document.Module,
Options: documentOptions(document.Options),
Options: pipeline.CloneModuleOptions(document.Options),
}
if document.LLMProfile != nil {
binding.LLMProfile = *document.LLMProfile
@@ -248,29 +248,3 @@ func documentReferencesToRuntime(documents map[string]ReferenceDocument) map[str
}
return references
}
func documentOptions(values map[string]any) map[string]any {
if values == nil {
return nil
}
result := make(map[string]any, len(values))
for key, value := range values {
result[key] = cloneDocumentOption(value)
}
return result
}
func cloneDocumentOption(value any) any {
switch typed := value.(type) {
case map[string]any:
return documentOptions(typed)
case []any:
result := make([]any, len(typed))
for index, item := range typed {
result[index] = cloneDocumentOption(item)
}
return result
default:
return typed
}
}