34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
using Volcanic.AgenticCore.Abstractions.Events;
|
|
using Volcanic.AgenticCore.Abstractions.Messages;
|
|
using Volcanic.AgenticCore.Testing;
|
|
using Volcanic.AgenticCore.Tests.Support;
|
|
|
|
namespace Volcanic.AgenticCore.Tests;
|
|
|
|
public class EndToEndTests
|
|
{
|
|
[Fact]
|
|
public async Task Host_runs_a_real_bash_tool_round_trip_through_the_loop()
|
|
{
|
|
if (OperatingSystem.IsWindows()) return;
|
|
await using var host = new TestHost(useFileStore: true);
|
|
await File.WriteAllTextAsync(Path.Combine(host.Cwd, "hello.txt"), "hi from disk");
|
|
host.Faux.Enqueue(
|
|
FauxTurn.Say("Reading the file.").WithTool("bash", new { command = "cat hello.txt" }),
|
|
FauxTurn.Say("The file says: hi from disk"));
|
|
await using var session = await host.CreateSessionAsync();
|
|
|
|
await session.PromptAsync("What does hello.txt contain?");
|
|
|
|
var toolResult = session.Messages.OfType<ToolResultMessage>().Single();
|
|
Assert.Equal("hi from disk", toolResult.Text);
|
|
Assert.False(toolResult.IsError);
|
|
Assert.Equal("The file says: hi from disk", session.Messages.OfType<AssistantMessage>().Last().Text);
|
|
Assert.Contains(host.Events, e => e is AgentSessionEvent.ToolExecutionEnd { ToolName: "bash", IsError: false });
|
|
|
|
// The session file exists on disk under the agent dir and can be listed.
|
|
var sessions = await host.Factory.ListSessionsAsync(host.Cwd);
|
|
Assert.Contains(sessions, s => s.SessionId == session.SessionId);
|
|
}
|
|
}
|