Description

Scenario run

Runs a Version9 scenario from backend/load/Scenario_.xml by executing its prompts as normal chat turns (tools allowed). Returns the final assistant message from the scenario.

Included in Version 6

Dynamically extracted tool implementation.
How to register ScenarioToolscsharp
registry.Register(new AgentTool(            "scenario_run",            "Runs a Version9 scenario from backend/load/Scenario_<Name>.xml by executing its <Step> prompts as normal chat turns (tools allowed). Returns the final assistant message from the scenario.",            args => RunScenarioTool(args),            new            {                type = "object",                properties = new                {                    scenario_name = new { type = "string", description = "Scenario name without prefix, e.g. 'OnBoot' loads Scenario_OnBoot.xml." }                },                required = new[] { "scenario_name" }            },            ToolCategory.Self        ));
Helper classes for ScenarioToolscsharp
    private string RunScenarioTool(string argumentsJson)    {        try        {            using var doc = JsonDocument.Parse(argumentsJson);            var root = doc.RootElement;            string scenarioName = root.TryGetProperty("scenario_name", out var n) ? (n.GetString() ?? "") : "";            if (string.IsNullOrWhiteSpace(scenarioName))                return "Error: scenario_name is required.";            string xml = ScenarioFileService.LoadScenarioXml(scenarioName);            var scenario = ScenarioXmlParser.Parse(xml);            // Execute scenario steps as chat turns; return final assistant message.            var branch = this.GetScenarioBranch();            string? last = ScenarioExecutor                .RunChatStepsAsync(branch, scenario.Steps, scenario.Id, scenario.Title)                .GetAwaiter().GetResult();            return string.IsNullOrWhiteSpace(last) ? "Completed." : last;        }        catch (Exception ex)        {            return $"Error: {ex.Message}";        }    }