Skip to content

test: add ConversationCompactor tests covering all 5 compaction modes and anti-thrash guards #29

@fuseraft

Description

@fuseraft

src/Orchestration/ConversationCompactor.cs (~700 lines) is one of the most complex classes in the codebase — it implements 5 compaction modes (llm, lossless, hybrid, window, intent), anti-thrash guards, reasoning block handling, and symbol-graph injection — but has no test file.

The existing test suite (tests/FuseraftCli.Tests/) covers validators, strategies, and orchestrators but nothing in ConversationCompactor.

Suggested test file: tests/FuseraftCli.Tests/ConversationCompactorTests.cs

Cases to cover at minimum:

  • ShouldCompact returns false when history is below threshold
  • ShouldCompact returns false when anti-thrash guard fires (last N compactions saved < AntiThrashMinSavingsRatio)
  • TrimToWindow truncates history to MaxConversationAge turns
  • lossless mode produces a deterministic output without calling the LLM
  • window mode drops old turns and keeps the system prompt
  • hybrid mode falls back to lossless if the LLM call fails
  • IncludeReasoning = false strips thinking blocks from output
  • Empty history and single-turn history don't throw
  • Post-compaction message count is less than pre-compaction count

The LLM dependency should be faked via the existing IChatClient test patterns already used in MagenticOrchestratorTests.cs.

Files to touch:

  • tests/FuseraftCli.Tests/ConversationCompactorTests.cs (new file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions