fix dynamic builder runtime mapping for option responses
Allow builder-native response kinds like OPTION to resolve to DYNAMIC so schema-driven definition creation succeeds. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3d1b3ad9b8
commit
9da9eb77e5
|
|
@ -221,7 +221,11 @@ func ResolveRuntimeQuestionTypeFromDefinition(key string, responseKinds []string
|
|||
return "TRUE_FALSE"
|
||||
}
|
||||
|
||||
hasNonAuxiliary := false
|
||||
for _, kind := range normalizeKindList(responseKinds) {
|
||||
if _, aux := responseKindsAuxiliary[kind]; !aux {
|
||||
hasNonAuxiliary = true
|
||||
}
|
||||
switch kind {
|
||||
case string(ResponseAudioResponse):
|
||||
return "AUDIO"
|
||||
|
|
@ -237,6 +241,11 @@ func ResolveRuntimeQuestionTypeFromDefinition(key string, responseKinds []string
|
|||
}
|
||||
}
|
||||
|
||||
// Builder-native response kinds should still be persistable/executable as DYNAMIC.
|
||||
if hasNonAuxiliary {
|
||||
return "DYNAMIC"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,13 @@ func TestResolveRuntimeQuestionTypeFromDefinition_skipsAuxiliaryKinds(t *testing
|
|||
}
|
||||
}
|
||||
|
||||
func TestResolveRuntimeQuestionTypeFromDefinition_builderNativeKinds(t *testing.T) {
|
||||
got := ResolveRuntimeQuestionTypeFromDefinition("dynamic_builder", []string{"OPTION", "ANSWER_TIMER"})
|
||||
if got != "DYNAMIC" {
|
||||
t.Fatalf("expected DYNAMIC, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatePersistableQuestionTypeDefinition_unmappable(t *testing.T) {
|
||||
err := ValidatePersistableQuestionTypeDefinition("custom", []string{"ANSWER_TIMER"})
|
||||
if err == nil || !strings.Contains(err.Error(), "unable to map definition") {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user