diff --git a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs index 0e4484b7..e03e6352 100644 --- a/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs +++ b/src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Execute.cs @@ -238,6 +238,11 @@ public partial class InstructService Text = result?.Result?.ToString() }; + if (context?.Arguments != null) + { + context.Arguments.ForEach(x => state.SetState(x.Key, x.Value, source: StateSource.External)); + } + // After code execution foreach (var hook in hooks) { @@ -249,7 +254,7 @@ public partial class InstructService Model = string.Empty, TemplateName = scriptName, UserMessage = message.Content, - SystemInstruction = string.Empty, + SystemInstruction = context?.CodeScript, CompletionText = response.Text }); }