From 7c9794f8d4d05074b96bb525d19db4ee1f6b3e95 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Tue, 11 Aug 2026 21:53:57 +0900 Subject: Complete runtime diagnostics and verification coverage --- tests/Agent.Core.Tests/ConfigurationTests.cs | 32 ++++++++++++++++++++++++ tests/Agent.Core.Tests/PromptAndRuntimeTests.cs | 4 +-- tests/Agent.Windows.Tests/SecurityPolicyTests.cs | 11 ++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Agent.Core.Tests/ConfigurationTests.cs b/tests/Agent.Core.Tests/ConfigurationTests.cs index e84d132..f6db9f2 100644 --- a/tests/Agent.Core.Tests/ConfigurationTests.cs +++ b/tests/Agent.Core.Tests/ConfigurationTests.cs @@ -1,5 +1,7 @@ using Agent.App.Cli; using Agent.App.Configuration; +using Agent.App; +using Agent.Core.Localization; using Agent.Core.Skills; namespace Agent.Core.Tests; @@ -100,6 +102,36 @@ public sealed class ConfigurationTests Assert.Contains(Path.GetFullPath(executable), error.Message, StringComparison.OrdinalIgnoreCase); } + [Fact] + public void Runtime_configuration_values_are_propagated() + { + var configuration = new AgentConfiguration + { + Agent = new RuntimeOptions { MaxIterations = 41, SameFailureLimit = 4 }, + Planner = new PlannerOptions { MaxTasks = 17 }, + Ollama = new OllamaConfiguration { Model = "model-x", Options = new OllamaGenerationOptions { NumCtx = 12345 } }, + Limits = new LimitOptions { ContextSummaryRatio = 0.65 } + }; + LocaleCatalog locale = LocaleCatalog.Load(Path.GetFullPath("config/locales"), "ja"); + + Agent.Core.Runtime.AgentRuntimeSettings settings = Program.CreateRuntimeSettings(configuration, "prompt", "ja", [], locale); + + Assert.Equal(41, settings.MaxIterations); + Assert.Equal(4, settings.SameFailureLimit); + Assert.Equal(17, settings.MaxTasks); + Assert.Equal(12345, settings.NumCtx); + Assert.Equal(0.65, settings.ContextSummaryThreshold); + Assert.Equal("model-x", settings.Model); + } + + [Fact] + public void Startup_errors_follow_the_cli_locale() + { + string message = Program.FormatStartupError(["--lang", "ja"], new CommandLineException("bad option")); + Assert.Contains("コマンドラインが不正です", message, StringComparison.Ordinal); + Assert.Contains("bad option", message, StringComparison.Ordinal); + } + [Fact] public void SkillLoader_loads_standard_skill_directories_only() { diff --git a/tests/Agent.Core.Tests/PromptAndRuntimeTests.cs b/tests/Agent.Core.Tests/PromptAndRuntimeTests.cs index 85aba56..836ed5e 100644 --- a/tests/Agent.Core.Tests/PromptAndRuntimeTests.cs +++ b/tests/Agent.Core.Tests/PromptAndRuntimeTests.cs @@ -173,8 +173,8 @@ public sealed class PromptAndRuntimeTests Assert.True(registry.TryGet(task.TaskId, null, out TaskSnapshot? failed)); Assert.Equal(AgentTaskState.Failed, failed!.State); Assert.Contains("Replan did not change", failed.Result, StringComparison.OrdinalIgnoreCase); - Assert.Equal("policy_denied", failed.LastErrorCode); - Assert.Contains("not approved for Read", failed.LastError, StringComparison.OrdinalIgnoreCase); + Assert.Equal("planning.replan_unchanged", failed.LastErrorCode); + Assert.Contains("Replan did not change", failed.LastError, StringComparison.OrdinalIgnoreCase); Assert.True(ollama.CallCount >= 1, $"Expected at least 1 call, got {ollama.CallCount}"); Assert.True(backend.CallCount >= 1, $"Expected at least 1 backend call, got {backend.CallCount}"); } diff --git a/tests/Agent.Windows.Tests/SecurityPolicyTests.cs b/tests/Agent.Windows.Tests/SecurityPolicyTests.cs index 7489dad..da6b325 100644 --- a/tests/Agent.Windows.Tests/SecurityPolicyTests.cs +++ b/tests/Agent.Windows.Tests/SecurityPolicyTests.cs @@ -14,6 +14,17 @@ namespace Agent.Windows.Tests; public sealed class SecurityPolicyTests { + [Fact] + public void Process_timeout_uses_configured_default_and_rejects_higher_values() + { + using JsonDocument omitted = JsonDocument.Parse("{}"); + Assert.Equal(45, WindowsToolBackend.ResolveProcessTimeout(omitted.RootElement, 45)); + using JsonDocument exact = JsonDocument.Parse("{\"timeout_seconds\":45}"); + Assert.Equal(45, WindowsToolBackend.ResolveProcessTimeout(exact.RootElement, 45)); + using JsonDocument tooHigh = JsonDocument.Parse("{\"timeout_seconds\":46}"); + Assert.Throws(() => WindowsToolBackend.ResolveProcessTimeout(tooHigh.RootElement, 45)); + } + [Fact] public void Read_write_and_delete_capabilities_are_independent() { -- cgit v1.2.3