OllamaLiveTests.cscsharp

Documentation

Version 1 design tests

Automated checks for chat and saved history (/history, /new, XML sessions under %AppData%/AgentCore/Version 1/ChatHistory).

Quick run

# From repo root (builds + offline unit tests)
python src/Version1/DesignTests/run-design-tests.py

# With live Ollama chat (localhost:11434, model gemma4)
python src/Version1/DesignTests/run-design-tests.py --live
.\src\Version1\DesignTests\run-design-tests.ps1
.\src\Version1\DesignTests\run-design-tests.ps1 -Live

What runs

| Suite | Needs network | Covers | |-------|----------------|--------| | ChatHistoryStoreTests | No | Save, list, load, session ids | | OllamaClientHistoryTests | No | Client save/load without HTTP | | OllamaLiveTests | Yes (--live) | Real StreamReply against Ollama |

dotnet only

dotnet test src/Version1/DesignTests/AgentCore.DesignTests.csproj
dotnet test src/Version1/DesignTests/AgentCore.DesignTests.csproj --filter "Category=Integration"

Set RUN_LIVE_TESTS=1 for integration tests without the Python runner.

Console video (testers)

Manual evidence runs use the shared test manager (records Lilith.exe):

python src/TestManager/test_manager.py list
python src/TestManager/test_manager.py record v1 chat-basic --build

See src/TestManager/README.md.

using System.Net.Http;using Agent.Core.Logging;using Agent.Core.Ollama;using Xunit;namespace Agent.Core.DesignTests;/// <summary>Requires Ollama at http://localhost:11434 and model gemma4. Run with --live.</summary>[Trait("Category", "Integration")]public class OllamaLiveTests{    [Fact]    public async Task Ollama_chat_returns_non_empty_reply()    {        Assert.True(LiveTestsEnabled(), "Set RUN_LIVE_TESTS=1 or pass --live to run-design-tests.py");        Assert.True(await OllamaReachableAsync(), "Ollama must be running at http://localhost:11434");        var logger = new Logger();        var client = new OllamaClient(logger) { Model = "gemma4" };        client.ClearHistory();        client.History.Add("system", "Reply with exactly: design-ok");        string reply = await client.StreamReply("Say the codeword.");        Assert.False(string.IsNullOrWhiteSpace(reply));    }    private static bool LiveTestsEnabled() =>        string.Equals(Environment.GetEnvironmentVariable("RUN_LIVE_TESTS"), "1", StringComparison.Ordinal);    private static async Task<bool> OllamaReachableAsync()    {        try        {            using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(3) };            using var response = await http.GetAsync("http://localhost:11434/api/tags");            return response.IsSuccessStatusCode;        }        catch        {            return false;        }    }}