Skip to content

fix(copilot): serialize session creation to prevent permission-denied race condition#30

Merged
jrob5756 merged 1 commit intomainfrom
fix/serialize-session-creation
Mar 9, 2026
Merged

fix(copilot): serialize session creation to prevent permission-denied race condition#30
jrob5756 merged 1 commit intomainfrom
fix/serialize-session-creation

Conversation

@jrob5756
Copy link
Copy Markdown
Collaborator

@jrob5756 jrob5756 commented Mar 9, 2026

Summary

  • Add asyncio.Lock around create_session in CopilotProvider to serialize concurrent session creation, preventing the SDK race condition where permission.request arrives for a not-yet-registered session
  • Sessions still run in parallel — only creation is serialized (~200ms per session, negligible vs workflow runtime)
  • Add tests verifying the lock exists and that concurrent acquisitions are serialized

Closes #29
Related: #27

Test plan

  • All 1641 existing tests pass
  • 2 new tests in TestSessionCreateLock verify lock existence and serialization behavior
  • Lint, format, and type checks pass

🤖 Generated with Claude Code

… race condition

Add an asyncio.Lock around create_session calls in CopilotProvider so
that concurrent for-each agents don't hit the SDK race where a
permission.request arrives for a session not yet registered in _sessions.
Sessions still run in parallel — only creation is serialized.

Closes #29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jrob5756 jrob5756 merged commit d879665 into main Mar 9, 2026
7 checks passed
@jrob5756 jrob5756 deleted the fix/serialize-session-creation branch March 9, 2026 13:41
jrob5756 pushed a commit that referenced this pull request Mar 9, 2026
The permission-denied errors in for-each groups are caused by a
regression in github-copilot-sdk 0.1.32, not the create_session race
condition we diagnosed in #27. Evidence: SDK 0.1.30 (Mar 7) had zero
permission denials; SDK 0.1.32 (Mar 8–9) fails consistently.

- Pin github-copilot-sdk to <0.1.32 until the regression is fixed
- Revert the _session_create_lock serialization from #30 since it
  addressed the wrong root cause

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jrob5756 added a commit that referenced this pull request Mar 9, 2026
* fix(copilot): pin SDK <0.1.32 and revert session serialization

The permission-denied errors in for-each groups are caused by a
regression in github-copilot-sdk 0.1.32, not the create_session race
condition we diagnosed in #27. Evidence: SDK 0.1.30 (Mar 7) had zero
permission denials; SDK 0.1.32 (Mar 8–9) fails consistently.

- Pin github-copilot-sdk to <0.1.32 until the regression is fixed
- Revert the _session_create_lock serialization from #30 since it
  addressed the wrong root cause

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(deps): tighten SDK pin to <0.1.31

SDK 0.1.31 also has the permission-denied regression (confirmed in
news repo run 22863258830). The last known good version is 0.1.30.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Jason Robert <jasonrobert@microsoft.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Serialize session creation to prevent permission-denied race condition

1 participant