Skip to content

.Net: Null reference error at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall #12288

Closed

Description

@karthiksimplist

Message: Object reference not set to an instance of an object.

Stack:
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall(String functionName, String functionArguments)
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionStep(OpenAIAssistantAgent agent, RunStep step)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items)
at System.Collections.Generic.SparseArrayBuilder1.ReserveOrAdd(IEnumerable1 items)
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.ToArray() at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList1 messages, RunCreationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList1 messages, RunCreationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult() at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func1 getActivity, Func1 operation, CancellationToken cancellationToken)+MoveNext() at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func1 getActivity, Func1 operation, CancellationToken cancellationToken)+MoveNext() at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func1 getActivity, Func`1 operation, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()

Activity

  1. changed the title [-]Null reference error at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall[/-] [+].NET: Null reference error at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall[/+] on May 28, 2025
  2. changed the title [-].NET: Null reference error at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall[/-] [+].Net: Null reference error at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.ParseFunctionCall[/+] on May 29, 2025
  3. moved this to Sprint: In Progress in Semantic Kernelon May 29, 2025
  4. crickman commented on May 29, 2025

    @crickman
    Contributor

    Not much going on within ParseFunctionCall...which made it easy to spot the likely candidate:

    Current: arguments[argumentKvp.Key] = argumentKvp.Value.ToString();

    Fixed: arguments[argumentKvp.Key] = argumentKvp.Value?.ToString();

    Was able to repro and verify fix with some sample hackery.

    Hope to have fix merged by tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codeagents

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions