@@ -11,10 +11,10 @@ import (
1111 "github.com/voocel/agentcore/schema"
1212)
1313
14- // AskUserResponse carries answers and optional user notes (from custom input) .
14+ // AskUserResponse carries answers and optional user notes.
1515type AskUserResponse struct {
1616 Answers map [string ]string // question text → answer
17- Notes map [string ]string // question text → custom note (only for "Type something")
17+ Notes map [string ]string // question text → user note (from "Type something" or preview notes )
1818}
1919
2020// AskUserHandler blocks until the user answers all questions.
@@ -33,6 +33,7 @@ type Question struct {
3333type Option struct {
3434 Label string `json:"label"`
3535 Description string `json:"description"`
36+ Preview string `json:"preview,omitempty"` // optional markdown preview content
3637}
3738
3839// AskUserTool lets the LLM ask the user structured questions.
@@ -63,6 +64,7 @@ func (t *AskUserTool) Schema() map[string]any {
6364 option := schema .Object (
6465 schema .Property ("label" , schema .String ("Display text (1-5 words)" )).Required (),
6566 schema .Property ("description" , schema .String ("What this option means" )).Required (),
67+ schema .Property ("preview" , schema .String ("Optional preview content (markdown) shown in a side panel when this option is focused" )),
6668 )
6769 question := schema .Object (
6870 schema .Property ("question" , schema .String ("The complete question to ask" )).Required (),
@@ -148,9 +150,16 @@ func formatAnswers(questions []Question, resp *AskUserResponse) string {
148150 continue
149151 }
150152 entry := fmt .Sprintf ("%q=%q" , q .Question , answer )
151- if note , hasNote := resp .Notes [q .Question ]; hasNote {
153+ if note , hasNote := resp .Notes [q .Question ]; hasNote && note != "" {
152154 entry += " user notes: " + note
153155 }
156+ // Include preview content of the selected option for context.
157+ for _ , opt := range q .Options {
158+ if opt .Label == answer && opt .Preview != "" {
159+ entry += " preview: " + opt .Preview
160+ break
161+ }
162+ }
154163 parts = append (parts , entry )
155164 }
156165 return fmt .Sprintf ("User has answered your questions: %s. You can now continue with the user's answers in mind." , strings .Join (parts , ", " ))
0 commit comments