Skip to content

Bug: AgentChat resume test intermittently throws NullReferenceException in fast suite #1577

Description

@JoshuaRowePhantom

Unrelated test failure — observed during checkin for #1493

Failing test: Phantom.Workspaces.Llm.Tests.AgentChatResumeTests.AgentChat_Resume_RunningSubAgents_StillResolveToSucceededWithPreservedTimestamp

Failure:

System.NullReferenceException: Object reference not set to an instance of an object.
at AgentChatResumeTests.AgentChat_Resume_RunningSubAgents_StillResolveToSucceededWithPreservedTimestamp() line 474

The failure occurred once in the fast suite (1 failure among 7,364 tests). No dump was produced. The exact test then passed 10/10 isolated runs, and the complete AgentChatResumeTests class passed 10/10 runs.

Why this is unrelated to #1493

The #1493 diff does not modify AgentChatResumeTests, SubAgent, AgentChatFactory, or RunningAgentChatLease. Its only AgentChat change adds/invokes a modal-response test hook; this restore test never enters modal-response code. The CTS disposal race fixed by #1493 is in RemoteAgentSessionLease.AttachmentPublisher; this failure has no remote-session stack or ObjectDisposedException, so it is not a recurrence of that race.

Root-cause hypothesis

This is suite-order/parallelism-sensitive lifetime interference around restored sub-agent lease acquisition or disposal. The source line contains an await using acquisition, so the generated state machine can attribute a null during acquisition/disposal to line 474 without exposing the originating object. Isolation removes the trigger.

Proposed solution

  1. Split acquisition and disposal in this regression test into explicit statements and assert stub and lease before use so the next occurrence identifies which value is unexpectedly null.
  2. Add a stress test that runs restored child materialization and parent/factory disposal concurrently.
  3. Audit AgentChatFactory.ReleaseAsync/DisposeAsync coordination so factory disposal cannot clear entries while a child lease acquisition or release is in flight.
  4. If shared AgentChat lifecycle tests mutate process-wide state, place them in a non-parallel xUnit collection or remove that shared state.

Activity

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

Metadata

Metadata

Labels

bugSomething isn't workingverified-locallyImplementation has been verified locally

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions