Skip to content

.Net: Bug: Null reference exception at Azure.AI.Agents.Persistent.RunStepDetailsUpdate.get_FunctionName() #12339

Closed

Description

@karthiksimplist

Describe the bug
Getting this exception when SK tries to make the file search tool call. This is intermittent.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Azure.AI.Agents.Persistent
  StackTrace:
   at Azure.AI.Agents.Persistent.RunStepDetailsUpdate.get_FunctionName()
   at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.<InvokeStreamingAsync>d__6.MoveNext()
   at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.<InvokeStreamingAsync>d__6.MoveNext()
   at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.<InvokeStreamingAsync>d__6.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.<RunWithActivityAsync>d__4`1.MoveNext()
   at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.<RunWithActivityAsync>d__4`1.MoveNext()
   at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.<RunWithActivityAsync>d__4`1.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.<InvokeStreamingAsync>d__23.MoveNext()
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.<InvokeStreamingAsync>d__23.MoveNext()
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.<InvokeStreamingAsync>d__23.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)

To Reproduce
Steps to reproduce the behavior:
Create a Vector Store
Create a Azure Agent Thread
Assign the Vector Store to the Azure Agent Thread
Add a file to the Vector Store
Try to access the file via user query using the following code.
If it works then try to delete the file from the vector store and ask to make the file search tool call again

await foreach (var streamingContent in azureAgent.InvokeStreamingAsync(streamContent, agentThread, cancellationToken: cts.Token))
where

azureAgent is {Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent}

streamContent is a string
agentThread is {Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgentThread}
cts is {System.Threading.CancellationTokenSource}

Expected behavior
Supposed to make the file search tool call and bring the results.

Screenshots

Platform

  • Language: C#
  • Source:
    <PackageReference Include="Azure.AI.Agents.Persistent" Version="1.1.0-beta.1" />
    <PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.9" />
    <PackageReference Include="Microsoft.SemanticKernel" Version="1.54.0" />
    <PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.54.0" />
    <PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.54.0" />
    <PackageReference Include="Microsoft.SemanticKernel.Agents.AzureAI" Version="1.54.0-preview" />
  • AI model: [OpenAI:GPT-4o]
  • IDE: [e.g. Visual Studio]
  • OS: [e.g. Windows]

Additional context
Add any other context about the problem here.

Activity

  1. changed the title [-]Bug: Null reference exception at Azure.AI.Agents.Persistent.RunStepDetailsUpdate.get_FunctionName()[/-] [+].Net: Bug: Null reference exception at Azure.AI.Agents.Persistent.RunStepDetailsUpdate.get_FunctionName()[/+] on Jun 2, 2025
  2. karthiksimplist commented on Jun 2, 2025

    @karthiksimplist
    Author

    The actual calls on the thread works fine as I could see the results on the Azure AI Foundry UI threads. It's just the SK throwing this error when it tries to handle the request/repose.

    also, getting the following error around the same line - not sure when we would get the error I reported on the bug vs this one.

    
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.InvokeStreamingAsync(AzureAIAgent agent, PersistentAgentsClient client, String threadId, IList`1 messages, AzureAIInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext()
       at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.InvokeStreamingAsync(AzureAIAgent agent, PersistentAgentsClient client, String threadId, IList`1 messages, AzureAIInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext()
       at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.InvokeStreamingAsync(AzureAIAgent agent, PersistentAgentsClient client, String threadId, IList`1 messages, AzureAIInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
       at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+MoveNext()
       at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+MoveNext()
       at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
       at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.InvokeStreamingAsync(ICollection`1 messages, AgentThread thread, AzureAIAgentInvokeOptions options, CancellationToken cancellationToken)+MoveNext()
    
  3. markharrison commented on Jun 2, 2025

    @markharrison

    I have a similar problem - this code works for an AI Foundry Agent when I dont have Bing defined as Knowledge. It gives an Exception when is Bing is set up as Knowledge.

    Image

    versions:

    <PackageReference Include="Azure.AI.Agents.Persistent" Version="1.1.0-beta.1" />
    <PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.9" />
    <PackageReference Include="Azure.Identity" Version="1.14.0" />
    <PackageReference Include="DotNetEnv" Version="3.1.1" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0-preview.4.25258.110" />
    <PackageReference Include="Microsoft.SemanticKernel" Version="1.54.0" />
    <PackageReference Include="Microsoft.SemanticKernel.Agents.AzureAI" Version="1.54.0-preview" />
    <PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.54.0" />
    <PackageReference Include="Microsoft.SemanticKernel.Process.Abstractions" Version="1.54.0-alpha" />
    <PackageReference Include="Microsoft.SemanticKernel.Process.Core" Version="1.54.0-alpha" />
    <PackageReference Include="Microsoft.SemanticKernel.Process.LocalRuntime" Version="1.54.0-alpha" />
    <PackageReference Include="Polly" Version="8.5.2" />
    

    --

    After thought - not sure its similar ... ill open a separate issue . #12351

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 codebugSomething isn't working

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions