forked from admin/VolcanicAgenticCore
test(telegram): relogin test deactivates host tools such as set_timezone
The fake claude never starts the proposal bridge, so the test needs a session with no active tools. Since the scheduler spec every chat registers set_timezone, which made the provider wait for the bridge and fail with mcp_startup on Linux (the test returns early on Windows).
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Telegram.Bot.Types.ReplyMarkups;
|
using Telegram.Bot.Types.ReplyMarkups;
|
||||||
|
using Volcanic.AgenticCore.Abstractions.Extensions;
|
||||||
|
using Volcanic.AgenticCore.Abstractions.Extensions.Events;
|
||||||
using Volcanic.AgenticCore.Extensions.ClaudeCode;
|
using Volcanic.AgenticCore.Extensions.ClaudeCode;
|
||||||
using Volcanic.AgenticCore.Telegram.Chats;
|
using Volcanic.AgenticCore.Telegram.Chats;
|
||||||
using Volcanic.AgenticCore.Telegram.Tests.Support;
|
using Volcanic.AgenticCore.Telegram.Tests.Support;
|
||||||
@@ -87,7 +89,10 @@ public sealed class ClaudeCodeReloginTests : IDisposable
|
|||||||
}),
|
}),
|
||||||
core =>
|
core =>
|
||||||
{
|
{
|
||||||
core.IncludeBuiltInTools = false; // no tools: the fake needs no proposal bridge
|
// No tools: the fake needs no proposal bridge. Host extensions still register tools (set_timezone in
|
||||||
|
// every chat), so NoTools deactivates them once the session has started.
|
||||||
|
core.IncludeBuiltInTools = false;
|
||||||
|
core.AddExtension(new NoTools());
|
||||||
core.AddExtension<ClaudeCodeProviderExtension>();
|
core.AddExtension<ClaudeCodeProviderExtension>();
|
||||||
});
|
});
|
||||||
host.Options.Model = "claude-code/sonnet";
|
host.Options.Model = "claude-code/sonnet";
|
||||||
@@ -97,7 +102,13 @@ public sealed class ClaudeCodeReloginTests : IDisposable
|
|||||||
|
|
||||||
// The link and the code question reach the owner (the first allowed user), not the requester.
|
// The link and the code question reach the owner (the first allowed user), not the requester.
|
||||||
var owner = await host.ChatAsync(Updates.AllowedUser);
|
var owner = await host.ChatAsync(Updates.AllowedUser);
|
||||||
await Wait.UntilAsync(() => owner.Ui.IsWaitingForInput, "the login code question in the owner chat", 15000);
|
try { await Wait.UntilAsync(() => owner.Ui.IsWaitingForInput, "the login code question in the owner chat", 5000); }
|
||||||
|
catch (TimeoutException)
|
||||||
|
{
|
||||||
|
foreach (var s in host.Bot.Sent) Console.Error.WriteLine($"SENT {s.ChatId.Identifier}: {s.Text}");
|
||||||
|
Console.Error.WriteLine("RUNS: " + (File.Exists(Path.Combine(_root, "state", "runs")) ? File.ReadAllText(Path.Combine(_root, "state", "runs")) : "none"));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
var prompt = Assert.Single(host.Bot.Sent, s => s.Text.Contains("oauth/authorize?state=owner", StringComparison.Ordinal));
|
var prompt = Assert.Single(host.Bot.Sent, s => s.Text.Contains("oauth/authorize?state=owner", StringComparison.Ordinal));
|
||||||
Assert.Equal(Updates.AllowedUser, prompt.ChatId.Identifier);
|
Assert.Equal(Updates.AllowedUser, prompt.ChatId.Identifier);
|
||||||
Assert.IsType<ForceReplyMarkup>(prompt.ReplyMarkup);
|
Assert.IsType<ForceReplyMarkup>(prompt.ReplyMarkup);
|
||||||
@@ -115,6 +126,22 @@ public sealed class ClaudeCodeReloginTests : IDisposable
|
|||||||
Assert.Equal(2, File.ReadAllLines(Path.Combine(_root, "state", "runs")).Length);
|
Assert.Equal(2, File.ReadAllLines(Path.Combine(_root, "state", "runs")).Length);
|
||||||
Assert.Empty(host.Faux.Requests);
|
Assert.Empty(host.Faux.Requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Deactivates every tool at session start, including those host extensions registered.</summary>
|
||||||
|
private sealed class NoTools : IExtension
|
||||||
|
{
|
||||||
|
public string Name => "no-tools";
|
||||||
|
|
||||||
|
public ValueTask ActivateAsync(IExtensionApi api, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
api.On<SessionStartEvent>((_, _, _) =>
|
||||||
|
{
|
||||||
|
api.SetActiveTools([]);
|
||||||
|
return ValueTask.CompletedTask;
|
||||||
|
});
|
||||||
|
return ValueTask.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user