feat(agent): clarify vague briefs before generating and harden prompts
Let the planner return a clarify/chat intent that asks 2-4 targeted questions (imageCount 0) when essentials are missing, instead of forging ahead. Tighten prompt guidance to preserve user wording and stated reference-image roles, avoid inventing copy/specs, keep durable brand constraints, and treat vague taste feedback as clarification. Also fix the generation heartbeat goroutine to stop cleanly via defer, add research-query fallbacks, and refresh image-only capability copy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package piagent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
@@ -37,3 +38,33 @@ func TestAgentMessageContentSummaryDoesNotLeakImageURLs(t *testing.T) {
|
||||
t.Fatalf("expected compact inline text summary, got %d runes", utf8.RuneCountInString(summary))
|
||||
}
|
||||
}
|
||||
|
||||
func TestResearchContextIncludesPageContentForEveryResult(t *testing.T) {
|
||||
payload, err := json.Marshal(design.ResearchReport{
|
||||
Kind: "web_search",
|
||||
Source: "test",
|
||||
Query: "Japanese bakery brand identity",
|
||||
Results: []design.ResearchResult{
|
||||
{Title: "Bakery case study", URL: "https://example.com/one", Snippet: "Warm handmade identity.", Content: "Detailed first webpage content about packaging, signage, and illustration."},
|
||||
{Title: "Brand identity notes", URL: "https://example.com/two", Snippet: "Soft visual system.", Content: "Detailed second webpage content about colors, typography, and bakery tone."},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
context := researchContext([]design.Message{
|
||||
{Role: "tool", Type: "tool", Title: "Synthesize Skills", Content: string(payload)},
|
||||
})
|
||||
for _, want := range []string{
|
||||
"Query: Japanese bakery brand identity",
|
||||
"https://example.com/one",
|
||||
"Detailed first webpage content",
|
||||
"https://example.com/two",
|
||||
"Detailed second webpage content",
|
||||
} {
|
||||
if !strings.Contains(context, want) {
|
||||
t.Fatalf("expected research context to include %q, got %s", want, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user