test: consolidate capture/script fake chat clients into a shared helper (#1599) - #1602
Merged
Aaronontheweb merged 1 commit intoJul 8, 2026
Conversation
…er (netclaw-dev#1599) Adds a single configurable Netclaw.Tests.Utilities.FakeChatClient (captures messages/options, scripted per-call responses, per-call usage, delay, throw; trivial usage-surfacing streaming) and migrates the near-identical one-off fakes onto it, deleting ~9 duplicate/near-duplicate classes: - SubAgents: delete the copied FakeChatClient and ThrowingChatClient. - Channels: delete ImageCapturingChatClient (Slack + Discord), RecordingChatClient, ContextCapturingChatClient. - Sessions: delete OptionsCapturingChatClient (SidecarSessionCorrelationTests now uses the purpose-built Sessions FakeChatClient, which already captures options). - Memory: delete ScriptedCurationChatClient (evaluator-parity tests). - Tools: delete the NoOpChatClient copy. Deliberately left bespoke, because the stream shape / failure timing IS the assertion (a flag on a general fake would read worse, not better): FailingChatClient, HangingStreamingChatClient, ControlledStreamingChatClient, StreamingTimeoutTestChatClient, ParkingChatClient, SequencedToolCallChatClient. Deliberately left alone: the rich Sessions FakeChatClient (327 lines of domain-specific recall-planning/summarizer branching, used across ~10 files; folding it into a shared util would drag domain logic in) and the Daemon delegate-based FakeChatClient (separate assembly). Net -272 lines. Full Netclaw.Actors.Tests suite green (2551), slopwatch clean, copyright headers present.
Aaronontheweb
enabled auto-merge (squash)
July 8, 2026 17:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #1599. Follow-up to #1600 (which had to re-add a
UsageOverridehook to the sub-agent's ownFakeChatClientcopy because it couldn't reuse the Sessions one).What
Introduces one configurable
Netclaw.Tests.Utilities.FakeChatClient— captures messages/options (LastReceivedMessages,LastReceivedOptions,ReceivedMessagesByCall,CallCount), scripts responses (ResponseText,ResponseTextsByCall,ToolCallsOnFirstCall,AlwaysReturnToolCalls), and supports per-callUsageOverride,Delay, andFailure. Streaming is trivial (replaysGetResponseAsyncviaToChatResponseUpdates, which also surfacesUsage).Migrates the near-identical one-off fakes onto it and deletes ~9 duplicate/near-duplicate classes:
FakeChatClient,ThrowingChatClientImageCapturingChatClient(Slack + Discord),RecordingChatClient,ContextCapturingChatClientOptionsCapturingChatClient(Sidecar now uses the purpose-built Sessions fake, which already records options)ScriptedCurationChatClient(evaluator-parity tests)NoOpChatClientcopyNet −272 lines.
What is deliberately NOT consolidated
Per the "don't build a god-object fake" line:
FailingChatClient,HangingStreamingChatClient,ControlledStreamingChatClient,StreamingTimeoutTestChatClient,ParkingChatClient,SequencedToolCallChatClient.FakeChatClient(327 lines, domain-specific recall-planning/summarizer branching, used across ~10 files) stays put — folding it into a shared util would drag Sessions domain logic in.FakeChatClientstays (separate assembly, already a flexible design).Not in scope on
devThe
RecordingCurationChatClientand the secondScriptedCurationChatClientreferenced in #1599 live in three Memory-redesign test files that don't exist ondevyet (they're on the unmerged memory-embeddings line). They'll adopt the shared fake when that work lands.Validation
Netclaw.Actors.Tests: 2551 passed, 0 failed.Netclaw.Daemon.Testsbuilds clean (verifies theMicrosoft.Extensions.AI.Abstractionspackage ref added toNetclaw.Tests.Utilitiesripples safely).dotnet slopwatch analyze: 0 issues. Copyright headers: all present.