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:
Yared Yemane 2026-05-08 10:56:41 -07:00
parent 3d1b3ad9b8
commit 9da9eb77e5
2 changed files with 16 additions and 0 deletions

View File

@ -221,7 +221,11 @@ func ResolveRuntimeQuestionTypeFromDefinition(key string, responseKinds []string
return "TRUE_FALSE" return "TRUE_FALSE"
} }
hasNonAuxiliary := false
for _, kind := range normalizeKindList(responseKinds) { for _, kind := range normalizeKindList(responseKinds) {
if _, aux := responseKindsAuxiliary[kind]; !aux {
hasNonAuxiliary = true
}
switch kind { switch kind {
case string(ResponseAudioResponse): case string(ResponseAudioResponse):
return "AUDIO" 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 "" return ""
} }

View File

@ -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) { func TestValidatePersistableQuestionTypeDefinition_unmappable(t *testing.T) {
err := ValidatePersistableQuestionTypeDefinition("custom", []string{"ANSWER_TIMER"}) err := ValidatePersistableQuestionTypeDefinition("custom", []string{"ANSWER_TIMER"})
if err == nil || !strings.Contains(err.Error(), "unable to map definition") { if err == nil || !strings.Contains(err.Error(), "unable to map definition") {