X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/1e0b100b2d3d4af9f65daae7ede647ac9c388157..eb05edcf5d575e8a3b1040debfb57423312e8320:/prompt_test.go?ds=inline diff --git a/prompt_test.go b/prompt_test.go index 3e66fde..902cb86 100644 --- a/prompt_test.go +++ b/prompt_test.go @@ -11,7 +11,7 @@ import ( ) 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") @@ -24,15 +24,36 @@ func TestPromptNamesTheAgent(t *testing.T) { } 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}) + tools := promptTools() + 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) @@ -46,7 +67,7 @@ func TestAgentToolsAreStrictAndStable(t *testing.T) { require.NoError(t, err) for range 10 { - again, err := json.Marshal(agentTools()) + again, err := json.Marshal(promptTools()) require.NoError(t, err) require.Equal(t, first, again) }