Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/Netclaw.Actors.Tests/Sessions/LlmSessionIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,11 +1417,27 @@ await sessionManager.Ask<SessionJoined>(new JoinSession
}, TimeSpan.FromSeconds(3), cancellationToken: TestContext.Current.CancellationToken);

Assert.Equal(sessionId, ack.SessionId);
await AwaitAssertAsync(() =>
{
Assert.Equal(1, _fakeChatClient.CallCount);
return Task.CompletedTask;
}, TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(100), cancellationToken: TestContext.Current.CancellationToken);

// Poll until the turn is fully persisted. Checking CallCount alone is not
// sufficient — the in-memory journal persists asynchronously, so TurnCount
// can still be 0 at the moment CallCount first reaches 1. CallCount is
// intentionally NOT asserted inside the retry loop: if retries push it above
// the expected value, a strict equality check would loop forever rather than
// failing fast. Assert it once after the loop, when the actor is idle.
// JoinSession is idempotent for the same subscriber (Dictionary keyed by
// IActorRef), so repeated calls with the witness probe are safe.
var witness = CreateTestProbe("passivation-witness");
await AwaitAssertAsync(async () =>
{
var peek = await sessionManager.Ask<SessionJoined>(new JoinSession
{
SessionId = sessionId,
Subscriber = witness,
Filter = OutputFilter.TextOnly
}, TimeSpan.FromSeconds(1), cancellationToken: TestContext.Current.CancellationToken);
Assert.Equal(1, peek.TurnCount);
}, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(100), cancellationToken: TestContext.Current.CancellationToken);
Assert.Equal(1, _fakeChatClient.CallCount);

var rejoined = await sessionManager.Ask<SessionJoined>(new JoinSession
{
Expand Down
3 changes: 3 additions & 0 deletions src/Netclaw.Actors.Tests/Sessions/LlmSessionTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Netclaw.Actors.Hosting;
using Netclaw.Actors.Jobs;
using Netclaw.Configuration;

namespace Netclaw.Actors.Tests.Sessions;
Expand All @@ -30,6 +31,8 @@ protected sealed override void ConfigureServices(HostBuilderContext context, ISe
{
services.AddSingleton<IModelCapabilityResolver>(new FakeCapabilityResolver());
services.AddTestNetclawPaths();
services.AddSingleton(SecurityPolicyDefaults.Resolve(null));
services.AddSingleton<BackgroundJobDefinitionStore>();
ConfigureSessionServices(services);
services.AddLlmSessionCompositeRecords();
}
Expand Down
Loading