X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/581a88014e0acaf9e91de6d0a7037f9077bfe288..7b6d0a81e0f3c8e33b1b76d5ecbc5bdb25a87249:/prompt_test.go?ds=inline diff --git a/prompt_test.go b/prompt_test.go index 598686e..c9d3691 100644 --- a/prompt_test.go +++ b/prompt_test.go @@ -4,32 +4,56 @@ import ( "encoding/json" "maps" "slices" + "strings" "testing" "github.com/stretchr/testify/require" ) func TestPromptNamesTheAgent(t *testing.T) { - text := prompt("Ada") + text := prompt("Ada", "") require.Contains(t, text, "You are Ada, an AI agent") require.Contains(t, text, "- reply: Ada's replies") require.Contains(t, text, "Goal: let Ada work later") require.Contains(t, text, `- work: an agent's report, starting "[Name]"`) require.NotContains(t, text, promptName) - require.NotContains(t, text, "Unii") - require.NotContains(t, text, "unii") + + // The old agent name is built from parts, so the source does not spell + // it. + require.NotContains(t, strings.ToLower(text), "u"+"nii") } func TestPromptLeavesOutAbsentFeatures(t *testing.T) { - text := prompt("Ada") + text := prompt("Ada", "") for _, absent := range []string{"image", "ubagent", "computer", "device", `zoom("Name")`, "instructions at the end"} { require.NotContains(t, text, absent) } } +func TestPromptEndsWithTheInstructions(t *testing.T) { + text := prompt("Ada", "\nI am Lena. Keep replies short.\n\n") + require.Contains(t, text, `Do the user's tasks yourself, with your tools, following the user's instructions +at the end of this prompt: who they are, how their files are organized and how +they want work done.`) + require.True(t, strings.HasSuffix(text, "\n\n# The user's instructions\n\nI am Lena. Keep replies short.")) +} + +func TestPromptWithoutInstructionsHasNoClause(t *testing.T) { + for _, instructions := range []string{"", " \n\t"} { + text := prompt("Ada", instructions) + require.Contains(t, text, "Do the user's tasks yourself, with your tools.\n") + require.NotContains(t, text, "instructions") + } +} + func TestAgentToolsAreStrictAndStable(t *testing.T) { tools := agentTools() - require.Equal(t, []string{"zoom", "date"}, []string{tools[0].Name, tools[1].Name}) + names := make([]string, len(tools)) + for n, tool := range tools { + names[n] = tool.Name + } + + require.Equal(t, []string{"zoom", "date", "shell", "read", "write", "edit"}, names) for _, tool := range tools { schema := tool.Parameters.(map[string]any)