Fix idle timer review issues
This commit is contained in:
@@ -3,6 +3,8 @@ package app
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hjbdev/patterm/internal/mcp"
|
||||
)
|
||||
|
||||
// mkChild builds a Child without starting a PTY. Use sparingly — the
|
||||
@@ -164,6 +166,47 @@ func TestHelpSpawningPointsAtLifecycle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestAvailableToolsAdvertisesAllTimerTools makes sure orchestrators
|
||||
// and sub-agents discover the full timer surface via whoami — not just
|
||||
// timer_wait. Otherwise agents using whoami for orientation would never
|
||||
// learn about timer_set, timer_fire_when_idle_*, timer_pause/resume,
|
||||
// timer_cancel, and timer_list.
|
||||
func TestAvailableToolsAdvertisesAllTimerTools(t *testing.T) {
|
||||
want := []string{
|
||||
"timer_wait", "timer_set",
|
||||
"timer_fire_when_idle_any", "timer_fire_when_idle_all",
|
||||
"timer_cancel", "timer_pause", "timer_resume", "timer_list",
|
||||
}
|
||||
for _, role := range []mcp.CallerRole{mcp.RoleOrchestrator, mcp.RoleSubAgent} {
|
||||
tools := availableToolsForRole(role)
|
||||
for _, w := range want {
|
||||
if !containsString(tools, w) {
|
||||
t.Fatalf("role %q missing %q in available tools: %v", role, w, tools)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestHelpTimersDocumentsAllTools mirrors the whoami check for the
|
||||
// help("timers") topic — the related-tools list must enumerate every
|
||||
// timer_* tool so callers reading help can dispatch them.
|
||||
func TestHelpTimersDocumentsAllTools(t *testing.T) {
|
||||
resp := helpFor("timers")
|
||||
if resp.Topic != "timers" {
|
||||
t.Fatalf("topic: %q", resp.Topic)
|
||||
}
|
||||
want := []string{
|
||||
"timer_wait", "timer_set",
|
||||
"timer_fire_when_idle_any", "timer_fire_when_idle_all",
|
||||
"timer_cancel", "timer_pause", "timer_resume", "timer_list",
|
||||
}
|
||||
for _, w := range want {
|
||||
if !containsString(resp.RelatedTools, w) {
|
||||
t.Fatalf("timers help missing %q in related tools: %v", w, resp.RelatedTools)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func containsString(haystack []string, needle string) bool {
|
||||
for _, s := range haystack {
|
||||
if s == needle {
|
||||
@@ -172,4 +215,3 @@ func containsString(haystack []string, needle string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user