Skip to content

Commit 448181b

Browse files
authored
Assistant - Fix null-reference exception when accessing RunStepDetailsUpdate.FunctionName (#293)
The propertis for `RunStepDetailsUpdate` all fall-through for null internal definitions, except for `FunctionName`...which results in a `NullReferenceException`. This is inconsistent with the expected behavior. This complicates inspection when _file-search_ and _functions_ are both enabled.
1 parent 539172f commit 448181b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Custom/Assistants/Streaming/RunStepDetailsUpdate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IReadOnlyList<RunStepUpdateCodeInterpreterOutput> CodeInterpreterOutputs
4545
=> _asCodeCall?.CodeInterpreter?.Outputs;
4646

4747
/// <inheritdoc cref="InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Name"/>
48-
public string FunctionName => _asFunctionCall.Function?.Name;
48+
public string FunctionName => _asFunctionCall?.Function?.Name;
4949

5050
/// <inheritdoc cref="InternalRunStepDeltaStepDetailsToolCallsFunctionObjectFunction.Arguments"/>
5151
public string FunctionArguments => _asFunctionCall?.Function?.Arguments;

tests/Assistants/AssistantsTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,12 @@ public async Task BasicFileSearchStreamingWorks()
10151015
{
10161016
message += $"{contentUpdate.Text}";
10171017
}
1018+
else if (update is RunStepDetailsUpdate detailUpdate)
1019+
{
1020+
string? functionName = "none"; // expect null assignment on next line
1021+
Assert.DoesNotThrow(() => functionName = detailUpdate.FunctionName);
1022+
Assert.Null(functionName);
1023+
}
10181024
}
10191025
}
10201026
else

0 commit comments

Comments
 (0)