Summary
Consolidate the divergent FakeChatClient test doubles into one shared helper in Netclaw.Tests.Utilities. Tracked follow-up to #1597 (whose fix intentionally added a small UsageOverride to the sub-agent FakeChatClient rather than blocking on this refactor).
Problem
There are three distinct classes literally named FakeChatClient, which have diverged in capability:
| File |
Namespace |
Notable capabilities |
src/Netclaw.Actors.Tests/Sessions/LlmSessionIntegrationTests.cs |
Netclaw.Actors.Tests.Sessions |
PlannedResponses, PlannedToolCallDecisions, UsageOverride, PlannedUsageOverrides, IncludeThinking, ObservationResponseOverride, … (feature-rich) |
src/Netclaw.Actors.Tests/SubAgents/SubAgentActorTests.cs |
Netclaw.Actors.Tests.SubAgents |
ToolCallsOnFirstCall, ResponseTextsByCall, Delay, AlwaysReturnToolCalls, UsageOverride (added in #1597) |
src/Netclaw.Daemon.Tests/Configuration/RetryingChatClientTests.cs |
Netclaw.Daemon.Tests.Configuration |
retry/failure-focused |
The duplication is why #1597 had to re-add UsageOverride to the sub-agent fake even though the Sessions fake already had it — a "reuse before you add" violation the constitution flags.
Scope
- In scope: unify the three
FakeChatClient classes into a single configurable fake in Netclaw.Tests.Utilities (already referenced by Netclaw.Actors.Tests, Netclaw.Daemon.Tests, and others), then migrate call sites.
- Out of scope: the ~15 bespoke, single-purpose fake
IChatClient implementations (ParkingChatClient, ThrowingChatClient, SequencedToolCallChatClient, HangingStreamingChatClient, ControlledStreamingChatClient, StreamingTimeoutTestChatClient, ImageCapturingChatClient, …). These intentionally encode one behavior each; folding them into one mega-fake would be a worse abstraction. Leave them alone.
Acceptance
- One
FakeChatClient in Netclaw.Tests.Utilities covers the union of capabilities the three current copies need (streaming + non-streaming, tool calls, planned responses, per-call/override usage, thinking, delay).
- Sessions / SubAgents / Daemon tests migrate onto it; the three duplicate definitions are deleted.
- Full test suite stays green; no behavior change to production code.
Summary
Consolidate the divergent
FakeChatClienttest doubles into one shared helper inNetclaw.Tests.Utilities. Tracked follow-up to #1597 (whose fix intentionally added a smallUsageOverrideto the sub-agentFakeChatClientrather than blocking on this refactor).Problem
There are three distinct classes literally named
FakeChatClient, which have diverged in capability:src/Netclaw.Actors.Tests/Sessions/LlmSessionIntegrationTests.csNetclaw.Actors.Tests.SessionsPlannedResponses,PlannedToolCallDecisions,UsageOverride,PlannedUsageOverrides,IncludeThinking,ObservationResponseOverride, … (feature-rich)src/Netclaw.Actors.Tests/SubAgents/SubAgentActorTests.csNetclaw.Actors.Tests.SubAgentsToolCallsOnFirstCall,ResponseTextsByCall,Delay,AlwaysReturnToolCalls,UsageOverride(added in #1597)src/Netclaw.Daemon.Tests/Configuration/RetryingChatClientTests.csNetclaw.Daemon.Tests.ConfigurationThe duplication is why #1597 had to re-add
UsageOverrideto the sub-agent fake even though the Sessions fake already had it — a "reuse before you add" violation the constitution flags.Scope
FakeChatClientclasses into a single configurable fake inNetclaw.Tests.Utilities(already referenced byNetclaw.Actors.Tests,Netclaw.Daemon.Tests, and others), then migrate call sites.IChatClientimplementations (ParkingChatClient,ThrowingChatClient,SequencedToolCallChatClient,HangingStreamingChatClient,ControlledStreamingChatClient,StreamingTimeoutTestChatClient,ImageCapturingChatClient, …). These intentionally encode one behavior each; folding them into one mega-fake would be a worse abstraction. Leave them alone.Acceptance
FakeChatClientinNetclaw.Tests.Utilitiescovers the union of capabilities the three current copies need (streaming + non-streaming, tool calls, planned responses, per-call/override usage, thinking, delay).