Skip to content

Commit e0e3fd6

Browse files
committed
Add assistantSkillTrigger test
- Ensure pipeline output is not logged for assistantSkillTrigger
1 parent a45209c commit e0e3fd6

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/DurableWorker/DurableController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public bool TryGetInputBindingParameterValue(string bindingName, out object valu
144144

145145
public void AddPipelineOutputIfNecessary(Collection<object> pipelineItems, Hashtable result)
146146
{
147-
148147
if (ShouldSuppressPipelineTraces())
149148
{
150149
var returnValue = FunctionReturnValueBuilder.CreateReturnValueFromFunctionOutput(pipelineItems);

src/PowerShell/PowerShellManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public Hashtable InvokeFunction(
243243
else
244244
{
245245
var isActivityFunction = functionInfo.DurableFunctionInfo.IsActivityFunction;
246-
if (!isActivityFunction)
246+
if (!isActivityFunction && !FunctionInfoUtilities.hasAssistantSkillTrigger(functionInfo))
247247
{
248248
_pwsh.AddCommand(Utils.TracePipelineObjectCmdlet);
249249
}

test/Unit/PowerShell/PowerShellManagerTests.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public void LoggerContextIsSet()
392392
[InlineData(DurableFunctionType.None, false)]
393393
[InlineData(DurableFunctionType.OrchestrationFunction, false)]
394394
[InlineData(DurableFunctionType.ActivityFunction, true)]
395-
internal void SuppressPipelineTracesForDurableActivityFunctionOnly(DurableFunctionType durableFunctionType, bool shouldSuppressPipelineTraces)
395+
internal void SuppressPipelineTracesForDurableActivityFunction(DurableFunctionType durableFunctionType, bool shouldSuppressPipelineTraces)
396396
{
397397
s_testLogger.FullLog.Clear();
398398

@@ -416,6 +416,41 @@ internal void SuppressPipelineTracesForDurableActivityFunctionOnly(DurableFuncti
416416
}
417417
}
418418

419+
[Theory]
420+
[InlineData("httpTrigger", false)]
421+
[InlineData("assistantSkillTrigger", true)]
422+
internal void SuppressPipelineTracesForOpenAIAssistantSkillTrigger(string inputBindingType, bool shouldSuppressPipelineTraces)
423+
{
424+
s_testLogger.FullLog.Clear();
425+
426+
var path = Path.Join(s_funcDirectory, "testFunctionWithOutput.ps1");
427+
428+
foreach(var binding in s_functionLoadRequest.Metadata.Bindings)
429+
{
430+
if (binding.Value.Direction == BindingInfo.Types.Direction.In)
431+
{
432+
binding.Value.Type = inputBindingType;
433+
}
434+
}
435+
436+
var (functionInfo, testManager) = PrepareFunction(path, string.Empty);
437+
438+
try
439+
{
440+
FunctionMetadata.RegisterFunctionMetadata(testManager.InstanceId, functionInfo.OutputBindings);
441+
442+
var result = testManager.InvokeFunction(functionInfo, null, null, null, CreateOrchestratorInputData(), new FunctionInvocationPerformanceStopwatch(), null);
443+
444+
var relevantLogs = s_testLogger.FullLog.Where(message => message.StartsWith("Information: OUTPUT:")).ToList();
445+
var expected = shouldSuppressPipelineTraces ? new string[0] : new[] { "Information: OUTPUT: Hello" };
446+
Assert.Equal(expected, relevantLogs);
447+
}
448+
finally
449+
{
450+
FunctionMetadata.UnregisterFunctionMetadata(testManager.InstanceId);
451+
}
452+
}
453+
419454
private static List<ParameterBinding> CreateOrchestratorInputData()
420455
{
421456
var orchestrationContext = new OrchestrationContext

0 commit comments

Comments
 (0)