MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / TestAgentStateCacheBreakpointsUsePythonKey

Function TestAgentStateCacheBreakpointsUsePythonKey

test/agent_test.go:984–1026  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

982 state.CacheBreakPoints.Add(2)
983 state.CacheBreakPoints.Add(5)
984 m, err := state.ToMap()
985 if err != nil {
986 t.Fatal(err)
987 }
988 if _, ok := m["cache_breakpoints"]; !ok {
989 t.Fatalf("expected Python-compatible cache_breakpoints key, got %#v", m)
990 }
991 if _, ok := m["cache_break_points"]; ok {
992 t.Fatalf("unexpected legacy cache_break_points key in serialized state: %#v", m)
993 }
994
995 restored, err := agent.GetAgentStateFromMap(map[string]any{
996 "cache_breakpoints": []any{float64(3), float64(7)},
997 })
998 if err != nil {
999 t.Fatal(err)
1000 }
1001 if !restored.CacheBreakPoints.Contains(3) || !restored.CacheBreakPoints.Contains(7) {
1002 t.Fatalf("expected Python cache_breakpoints to restore, got %#v", restored.CacheBreakPoints)
1003 }
1004
1005 legacy, err := agent.GetAgentStateFromMap(map[string]any{
1006 "cache_break_points": []any{float64(11)},
1007 })
1008 if err != nil {
1009 t.Fatal(err)
1010 }
1011 if !legacy.CacheBreakPoints.Contains(11) {
1012 t.Fatalf("expected legacy cache_break_points to restore, got %#v", legacy.CacheBreakPoints)
1013 }
1014
1015 defaulted, err := agent.GetAgentStateFromMap(map[string]any{})
1016 if err != nil {
1017 t.Fatal(err)
1018 }
1019 if defaulted.PermissionState == nil || defaulted.DeniedToolCalls == nil || defaulted.ToolErrors == nil || defaulted.CacheBreakPoints == nil {
1020 t.Fatalf("expected missing fields to use AgentState defaults, got %#v", defaulted)
1021 }
1022}
1023
1024func TestTaskRuntimeWaitReportsInaccessibleAndForgottenTasks(t *testing.T) {
1025 rt := agent.NewAgentTaskRuntime()
1026 rt.RegisterForegroundTask("child-other", "", "other-scope", "other", "desc", "Explore")
1027 inaccessible := rt.WaitForTasks(context.Background(), []string{"child-other"}, "main", 1)
1028 if !strings.Contains(inaccessible["error"].(string), "Unknown or inaccessible") {
1029 t.Fatalf("expected inaccessible error, got %#v", inaccessible)

Callers

nothing calls this directly

Calls 4

ToMapMethod · 0.95
NewAgentStateFunction · 0.92
GetAgentStateFromMapFunction · 0.92
AddMethod · 0.80

Tested by

no test coverage detected