Skip to content

Investigate Copilot SDK cancellation serialization bug #319

@PureWeen

Description

@PureWeen

Summary

Multi-agent orchestration sessions get stuck at IsProcessing=true when cancellation tokens fire. The root cause is a bug in the Copilot SDK where StreamJsonRpc.RequestId is not included in the AOT-safe JSON serialization context.

Symptoms

  • Orchestrator sessions show Thinking... forever
  • Crash log shows NotSupportedException for RequestId serialization at StreamJsonRpc.StandardCancellationStrategy.CancelOutboundRequest
  • 180s watchdog fires, response length is 0

Root Cause

SDK Bug: When a CancellationToken fires during an SDK call, StandardCancellationStrategy tries to serialize RequestId, but the SDK's SystemTextJsonFormatter doesn't include it in the TypeInfoResolverChain. The exception is unobserved, killing the JSON-RPC reader silently.

Workaround

PR implements workaround: pass CancellationToken.None to SDK SendAsync calls. Cancellation is handled at the TCS level via ResponseCompletion.TrySetCanceled().

Action Items

  • Decide whether to file issue on github/copilot-sdk
  • Monitor for SDK fix
  • Remove workaround once fixed

SDK Versions Affected

  • Broken: 0.1.30, 0.1.32
  • Works: 0.1.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions