Fix SKFunction.InvokeAsync to respect input when passed in explicitly. (#1757)

- The defaults for `mutableContext` are `true` which make it super easy
to fall into this trap. I slammed my head against the wall for a while
until realizing that the SK InvokeAsync method wasn't properly utilizing
the `input` parameter.

---------

Co-authored-by: Shawn Callegari <[email protected]>
This commit is contained in:
N. Taylor Mullen
2023-06-29 01:25:59 +00:00
committed by GitHub
co-authored by Shawn Callegari
parent de9c202a72
commit 6a370e7d13
@@ -125,18 +125,14 @@ public static class SKFunctionExtensions
function.SkillName, function.Name);
}
if (mutableContext)
if (!mutableContext)
{
context.Variables.Update(input);
return function.InvokeAsync(context, settings);
// Create a copy of the context, to avoid editing the original set of variables
context = context.Clone();
}
// Create a copy of the context, to avoid editing the original set of variables
SKContext contextClone = context.Clone();
// Store the input in the context clone
contextClone.Variables.Update(input);
return function.InvokeAsync(contextClone, settings);
// Store the input in the context
context.Variables.Update(input);
return function.InvokeAsync(context, settings);
}
}