Preserve message resource origins and profile credential lookup names
This commit is contained in:
@@ -66,37 +66,9 @@ func resolvePrompts(prompts map[string]map[string]promptConfig, resolution *conf
|
||||
if inputsChanged {
|
||||
resolution.Record(base.Key("inputs"), configkit.ChangeNormalization, "normalize input metadata")
|
||||
}
|
||||
messagesChanged := false
|
||||
for index := range definition.Messages {
|
||||
message := &definition.Messages[index]
|
||||
messagePath := base.Key("messages").Index(index)
|
||||
if message.Role != nil {
|
||||
role, err := domain.NormalizeMessageRole(*message.Role)
|
||||
if err != nil {
|
||||
resolution.Error(messagePath.Key("role"), err.Error())
|
||||
} else {
|
||||
messagesChanged = normalizeString(&message.Role, messagePath.Key("role"), resolution, role) || messagesChanged
|
||||
}
|
||||
}
|
||||
if control := message.CacheControl; control != nil && control.Type != nil {
|
||||
value := &domain.CacheControl{Type: domain.CacheControlType(*control.Type)}
|
||||
if control.TTL != nil {
|
||||
value.TTL = *control.TTL
|
||||
}
|
||||
normalized, err := domain.NormalizeCacheControl(value)
|
||||
if err != nil {
|
||||
resolution.Error(messagePath.Key("cache_control"), err.Error())
|
||||
} else {
|
||||
messagesChanged = normalizeString(&control.Type, messagePath.Key("cache_control").Key("type"), resolution, string(normalized.Type)) || messagesChanged
|
||||
if control.TTL != nil {
|
||||
messagesChanged = normalizeString(&control.TTL, messagePath.Key("cache_control").Key("ttl"), resolution, normalized.TTL) || messagesChanged
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if messagesChanged {
|
||||
resolution.Record(base.Key("messages"), configkit.ChangeNormalization, "normalize message metadata")
|
||||
}
|
||||
// Normalize message metadata on execution-owned copies below. ConfigKit
|
||||
// records sequence mutations as whole-value replacements, which would
|
||||
// discard the effective source contexts of unchanged content_file fields.
|
||||
if definition.Output != nil && definition.Output.SchemaPath != nil {
|
||||
normalizeString(&definition.Output.SchemaPath, base.Key("output").Key("schema_path"), resolution, strings.TrimSpace(*definition.Output.SchemaPath))
|
||||
}
|
||||
@@ -180,6 +152,10 @@ func (state *loaded) materializePrompt(id, version string, raw promptConfig, loo
|
||||
if message.Role == nil {
|
||||
return nil, fmt.Errorf("%s: role is required", path.Key("role"))
|
||||
}
|
||||
role, err := domain.NormalizeMessageRole(*message.Role)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %w", path.Key("role"), err)
|
||||
}
|
||||
if (message.Content != nil) == (message.ContentFile != nil) {
|
||||
return nil, fmt.Errorf("%s: exactly one of content or content_file is required", path)
|
||||
}
|
||||
@@ -214,7 +190,7 @@ func (state *loaded) materializePrompt(id, version string, raw promptConfig, loo
|
||||
}
|
||||
entry.messages = append(entry.messages, compiled)
|
||||
definition.Templates = append(definition.Templates, domain.PromptMessageTemplate{
|
||||
Role: *message.Role, Content: content, CacheControl: control,
|
||||
Role: role, Content: content, CacheControl: control,
|
||||
})
|
||||
}
|
||||
if raw.Output == nil {
|
||||
|
||||
Reference in New Issue
Block a user