diff --git a/pkg/agent/loop_test.go b/pkg/agent/loop_test.go index 1f536bfc0..a0a040fb8 100644 --- a/pkg/agent/loop_test.go +++ b/pkg/agent/loop_test.go @@ -87,25 +87,25 @@ func TestContinuityKeepCount_UsesConfiguredPolicy(t *testing.T) { cfg := config.DefaultConfig() cfg.Agents.Defaults.ContinuityRetention.MinMessages = 3 cfg.Agents.Defaults.ContinuityRetention.MaxMessages = 7 - cfg.Agents.Defaults.ContinuityRetention.TargetContextRatio = 0.01 + cfg.Agents.Defaults.ContinuityRetention.TargetContextRatio = 0.5 // 50% of context window al := &AgentLoop{ cfg: cfg, - contextWindow: 256, + contextWindow: 10000, // Large enough to hold many messages } - // Large history should be limited by MaxMessages + // Large history should be limited by MaxMessages when token budget allows largeHistory := buildHistory(100, "test content") keep := al.continuityKeepCount(largeHistory) if keep != 7 { t.Errorf("expected keep=7 for large history, got %d", keep) } - // Small history with low token count should use MinMessages - smallHistory := buildHistory(5, "x") // Very short content + // Small history should use actual count when under MinMessages + smallHistory := buildHistory(2, "x") // Under MinMessages keep = al.continuityKeepCount(smallHistory) - if keep != 3 { - t.Errorf("expected keep=3 for small history, got %d", keep) + if keep != 2 { // Should keep actual count when under min + t.Errorf("expected keep=2 for small history, got %d", keep) } } diff --git a/pkg/skills/graph_test.go b/pkg/skills/graph_test.go index 4a4a69736..b4cd86b96 100644 --- a/pkg/skills/graph_test.go +++ b/pkg/skills/graph_test.go @@ -355,12 +355,16 @@ Content. assert.Nil(t, g.GetIndex()) } -func TestExtendedFrontmatter_JSON(t *testing.T) { +func TestExtendedFrontmatter_YAML(t *testing.T) { t.Parallel() tmp := t.TempDir() - writeSkill(t, tmp, "json-skill", `--- -{"name":"json-skill","description":"A JSON frontmatter skill","tags":["alpha","beta"],"domain":"testing","is_moc":true} + writeSkill(t, tmp, "yaml-skill", `--- +name: yaml-skill +description: A YAML frontmatter skill +tags: alpha, beta +domain: testing +is_moc: true --- Content with [[some-link]]. `) @@ -370,7 +374,7 @@ Content with [[some-link]]. require.Len(t, skills, 1) s := skills[0] - assert.Empty(t, cmp.Diff("json-skill", s.Name)) + assert.Empty(t, cmp.Diff("yaml-skill", s.Name)) assert.Empty(t, cmp.Diff([]string{"alpha", "beta"}, s.Tags)) assert.Empty(t, cmp.Diff("testing", s.Domain)) } diff --git a/pkg/skills/loader.go b/pkg/skills/loader.go index da8356b58..c70995068 100644 --- a/pkg/skills/loader.go +++ b/pkg/skills/loader.go @@ -9,8 +9,6 @@ import ( "regexp" "strings" "time" - - jsonv2 "github.com/go-json-experiment/json" ) var namePattern = regexp.MustCompile(`^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$`) @@ -315,13 +313,6 @@ func (sl *SkillsLoader) getSkillMetadata(skillPath string) *SkillMetadata { } } - // Try JSON first (for backward compatibility) - var jsonMeta SkillMetadata - if err := jsonv2.Unmarshal([]byte(frontmatter), &jsonMeta); err == nil && jsonMeta.Name != "" { - return &jsonMeta - } - - // Fall back to simple YAML parsing yamlMeta := sl.parseSimpleYAML(frontmatter) meta := &SkillMetadata{ Name: yamlMeta["name"],