| 1 | package agent |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | // TestHeuristicInputIsTask covers the delivery evidence gate's task-vs-chat |
| 6 | // heuristic: greetings and acknowledgements must not arm the delivery gates, |
| 7 | // while actionable requests and failure descriptions must. |
| 8 | func TestHeuristicInputIsTask(t *testing.T) { |
| 9 | tests := []struct { |
| 10 | name string |
| 11 | input string |
| 12 | want bool |
| 13 | }{ |
| 14 | // Greetings / acknowledgements — chat. |
| 15 | {"hello", "hello", false}, |
| 16 | {"hi", "hi", false}, |
| 17 | {"你好", "你好", false}, |
| 18 | {"thanks", "thanks", false}, |
| 19 | {"谢谢", "谢谢", false}, |
| 20 | {"ok", "ok", false}, |
| 21 | {"好的", "好的", false}, |
| 22 | {"收到", "收到", false}, |
| 23 | {"我知道了", "我知道了", false}, |
| 24 | {"先不用", "先不用", false}, |
| 25 | |
| 26 | // Explicit tasks. |
| 27 | {"fix bug", "fix the bug", true}, |
| 28 | {"create component", "create a component", true}, |
| 29 | {"修复问题", "修复这个问题", true}, |
| 30 | {"run tests", "run tests", true}, |
| 31 | {"modify config", "modify config", true}, |
| 32 | {"make changes", "make the requested changes", true}, |
| 33 | {"adjust config", "调整现有配置", true}, |
| 34 | {"push branch", "push the branch", true}, |
| 35 | {"publish release", "publish release", true}, |
| 36 | {"看看", "帮我看看这个错误", true}, |
| 37 | {"帮我看下", "帮我看下这个问题", true}, |
| 38 | {"处理下", "处理下这个 issue", true}, |
| 39 | {"排查", "排查一下启动失败", true}, |
| 40 | {"定位", "定位这个异常", true}, |
| 41 | |
| 42 | // Conversational acknowledgements that contain task words. |
| 43 | {"thanks for fixing", "thanks for fixing that!", false}, |
| 44 | {"check later", "I'll check later", false}, |
| 45 | {"test later", "I'll test it later", false}, |
| 46 | {"test was helpful", "that test was helpful", false}, |
| 47 | {"辛苦了", "辛苦了", false}, |
| 48 | {"thanks then update", "thanks for fixing that, now update the tests", true}, |
| 49 | {"chinese thanks then update", "谢谢你,请继续修改配置", true}, |
| 50 | {"task before thanks", "review this PR; thanks for the help", true}, |
| 51 | |
| 52 | // Actionable problem descriptions without imperative verbs. |
| 53 | {"auth not working", "the auth isn't working", true}, |
| 54 | {"help with login", "can you help with login?", true}, |
| 55 | {"问题严重", "这个问题很严重", true}, |
| 56 | {"卡住了", "页面卡住了", true}, |
| 57 | {"没反应", "按钮点击没反应", true}, |
| 58 | {"不生效", "配置不生效", true}, |
| 59 | {"异常退出", "程序异常退出", true}, |
| 60 | |
| 61 | // File references. |
| 62 | {"file reference", "what about @auth.go", true}, |
| 63 | {"localized file reference", "检查(@配置.yaml)", true}, |
| 64 | {"python file", "check main.py", true}, |
| 65 | {"markdown file", "why does README.md render incorrectly", true}, |
| 66 | {"relative script", "why does ./scripts/verify.sh fail", true}, |
| 67 | {"email is not file reference", "thanks, email me@example.com later", false}, |
| 68 | {"long conversation is not task", "Remember ORBIT-42 and answer on the next turn please", false}, |
| 69 | {"durable memory is task", "Remember ORBIT-42 permanently across sessions", true}, |
| 70 | |
| 71 | // Edge cases. |
| 72 | {"empty", "", false}, |
| 73 | {"spaces", " ", false}, |
| 74 | {"question mark", "?", false}, |
| 75 | } |
| 76 | |
| 77 | for _, tt := range tests { |
| 78 | t.Run(tt.name, func(t *testing.T) { |
| 79 | if got := heuristicInputIsTask(tt.input); got != tt.want { |
| 80 | t.Errorf("heuristicInputIsTask(%q) = %v, want %v", tt.input, got, tt.want) |
| 81 | } |
| 82 | }) |
| 83 | } |
| 84 | } |
| 85 |