chore: update project files

This commit is contained in:
CJACK
2026-04-27 02:09:11 +08:00
parent 40d5e3ebb5
commit 90ce595325
27 changed files with 511 additions and 150 deletions

View File

@@ -30,11 +30,6 @@ func MessagesPrepareWithThinking(messages []map[string]any, thinkingEnabled bool
Text string
}
processed := make([]block, 0, len(messages))
if thinkingEnabled {
if instruction := buildConversationContinuityInstructions(thinkingEnabled); strings.TrimSpace(instruction) != "" {
processed = append(processed, block{Role: "system", Text: instruction})
}
}
for _, m := range messages {
role, _ := m["role"].(string)
text := NormalizeContent(m["content"])
@@ -93,17 +88,6 @@ func formatRoleBlock(marker, text, endMarker string) string {
return out
}
func buildConversationContinuityInstructions(thinkingEnabled bool) string {
lines := []string{
"Continue the conversation from the full prior context and the latest tool results.",
"Treat earlier messages as binding context; answer the user's current request as a continuation, not a restart.",
}
if thinkingEnabled {
lines = append(lines, "Keep reasoning internal. Do not leave the final user-facing answer only in reasoning; always provide the answer in visible assistant content.")
}
return strings.Join(lines, "\n")
}
func NormalizeContent(v any) string {
if v == nil {
return ""

View File

@@ -58,23 +58,14 @@ func TestNormalizeContentArrayFallsBackToContentWhenTextEmpty(t *testing.T) {
}
}
func TestMessagesPrepareWithThinkingAddsContinuityContract(t *testing.T) {
func TestMessagesPrepareWithThinkingPreservesPromptShape(t *testing.T) {
messages := []map[string]any{{"role": "user", "content": "Question"}}
gotThinking := MessagesPrepareWithThinking(messages, true)
gotPlain := MessagesPrepareWithThinking(messages, false)
if gotThinking == gotPlain {
t.Fatalf("expected thinking-enabled prompt to include extra continuity instructions")
if gotThinking != gotPlain {
t.Fatalf("expected thinking flag not to add extra continuity instructions, got thinking=%q plain=%q", gotThinking, gotPlain)
}
if !strings.HasSuffix(gotThinking, "<Assistant>") {
t.Fatalf("expected assistant suffix, got %q", gotThinking)
}
if !strings.Contains(gotThinking, "Continue the conversation from the full prior context") {
t.Fatalf("expected continuity instruction in thinking prompt, got %q", gotThinking)
}
if !strings.Contains(gotThinking, "final user-facing answer only in reasoning") {
t.Fatalf("expected visible-answer instruction in thinking prompt, got %q", gotThinking)
}
if strings.Contains(gotPlain, "Continue the conversation from the full prior context") {
t.Fatalf("did not expect thinking-only instruction in plain prompt, got %q", gotPlain)
}
}