Skip to content

test: consolidate capture/script fake chat clients into a shared helper (#1599) - #1602

Merged
Aaronontheweb merged 1 commit into
netclaw-dev:devfrom
Aaronontheweb:test/consolidate-fake-chat-clients
Jul 8, 2026
Merged

test: consolidate capture/script fake chat clients into a shared helper (#1599)#1602
Aaronontheweb merged 1 commit into
netclaw-dev:devfrom
Aaronontheweb:test/consolidate-fake-chat-clients

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Addresses #1599. Follow-up to #1600 (which had to re-add a UsageOverride hook to the sub-agent's own FakeChatClient copy 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-call UsageOverride, Delay, and Failure. Streaming is trivial (replays GetResponseAsync via ToChatResponseUpdates, which also surfaces Usage).

Migrates the near-identical one-off fakes onto it and deletes ~9 duplicate/near-duplicate classes:

Area Deleted
SubAgents copied FakeChatClient, ThrowingChatClient
Channels ImageCapturingChatClient (Slack + Discord), RecordingChatClient, ContextCapturingChatClient
Sessions OptionsCapturingChatClient (Sidecar now uses the purpose-built Sessions fake, which already records options)
Memory ScriptedCurationChatClient (evaluator-parity tests)
Tools the NoOpChatClient copy

Net −272 lines.

What is deliberately NOT consolidated

Per the "don't build a god-object fake" line:

  • Streaming/failure simulators stay bespoke — the precise stream shape or failure timing is the thing under test, so a small dedicated class reads clearer than a flag on a general fake: FailingChatClient, HangingStreamingChatClient, ControlledStreamingChatClient, StreamingTimeoutTestChatClient, ParkingChatClient, SequencedToolCallChatClient.
  • The rich Sessions 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.
  • The Daemon delegate-based FakeChatClient stays (separate assembly, already a flexible design).

Not in scope on dev

The RecordingCurationChatClient and the second ScriptedCurationChatClient referenced in #1599 live in three Memory-redesign test files that don't exist on dev yet (they're on the unmerged memory-embeddings line). They'll adopt the shared fake when that work lands.

Validation

  • Full Netclaw.Actors.Tests: 2551 passed, 0 failed. Netclaw.Daemon.Tests builds clean (verifies the Microsoft.Extensions.AI.Abstractions package ref added to Netclaw.Tests.Utilities ripples safely).
  • dotnet slopwatch analyze: 0 issues. Copyright headers: all present.

…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
Aaronontheweb enabled auto-merge (squash) July 8, 2026 17:16
@Aaronontheweb
Aaronontheweb merged commit 8c7e189 into netclaw-dev:dev Jul 8, 2026
15 checks passed
@Aaronontheweb
Aaronontheweb deleted the test/consolidate-fake-chat-clients branch July 8, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant