Keep prompt selection free of schema payloads

This commit is contained in:
2026-11-20 16:20:27 +00:00
parent 1bfb6eb301
commit 2c436d14d9
6 changed files with 30 additions and 6 deletions

View File

@@ -14,6 +14,28 @@ func schemaPrompt(id string, output map[string]any) map[string]any {
return map[string]any{"id": id, "messages": []any{map[string]any{"role": "user", "content": "hello"}}, "output": output}
}
func TestLightweightPromptSelectionKeepsSchemaInResourceView(t *testing.T) {
schema := map[string]any{"type": "object", "examples": make([]any, 1024)}
definition := schemaPrompt("selected", map[string]any{"format": "json", "validation_mode": "json_schema", "schema": schema})
definition["default_profile"] = "partial"
state, err := load(mapping("selection", map[string]any{
"profiles": []any{map[string]any{"id": "partial"}},
"prompts": []any{definition},
}), nil)
if err != nil {
t.Fatal(err)
}
selection, err := state.GetPromptInspection(context.Background(), "selected")
if err != nil || selection.PromptID != "selected" || selection.DefaultProfileID != "partial" {
t.Fatalf("selection = %+v, %v", selection, err)
}
// The selection type has no output contract; the full resource view still does.
resource, err := state.InspectPrompt(context.Background(), "selected")
if err != nil || resource.Output.Schema.(map[string]any)["type"] != "object" {
t.Fatalf("resource schema = %+v, %v", resource, err)
}
}
func TestSchemaFileCaptureUsesEffectiveSource(t *testing.T) {
first := configkit.NewFilesystem("first", fstest.MapFS{"a/placeholder": {Data: []byte("x")}, "a/schema.json": {Data: []byte("first")}})
second := configkit.NewFilesystem("second", fstest.MapFS{"b/placeholder": {Data: []byte("x")}, "b/schema.json": {Data: []byte("second")}})