]> git.giacomolli.uk - onechat/blobdiff - prompt_test.go
Name and order the tool code
[onechat] / prompt_test.go
index 3e66fde72cd3e2d2cf2b8f4c4cac54633ad584e4..902cb8677e7d3617f901e4b716c8237a229b701a 100644 (file)
@@ -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)
        }