SessionMetadataSnapshot.AlreadyInUse is always false for SDK-resumed sessions (never reflects concurrent use by another process)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
まず、dotnet/test/E2E/RpcSessionStateE2ETests.cs に記述されている resume と snapshot の動作を確認し、その後、対応する Go と Node.js のエンドツーエンドテストと比較します。SDK の resume 処理と session.metadata.snapshot の応答を追跡し、検出されたロック状態がどこで失われるのかを特定します。あるクライアントが保持しているセッションを別のクライアントが resume したときに AlreadyInUse=true を返し、新しいセッションでは false のままであれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
session.Rpc.Metadata.SnapshotAsync() returns a SessionMetadataSnapshot whose AlreadyInUse is always false when a session is opened through the SDK — even when the same session is concurrently held open by a different live process. The documented contract says this field should be true "when the session was detected to be in use by another process."
The in-use information clearly exists at the time of the call (a live per-process lock file is present on disk in the session directory), but it is not reflected in the snapshot. This affects both a default resume and a resume with SuppressResumeEvent = true.
Environment
- SDK:
GitHub.Copilot.SDK(.NET) v1.0.1 - Bundled Copilot CLI: 1.0.63 (managed automatically by the SDK)
- OS: Windows
- Note: the root cause appears to be server-side (Copilot CLI), since the .NET client deserializes
alreadyInUsestraight from thesession.metadata.snapshotRPC response. The same field exists in every language SDK (alreadyInUse/AlreadyInUse), so all clients are likely affected.
Expected behavior
Per the generated contract for SessionMetadataSnapshot.AlreadyInUse:
True when the session was detected to be in use by another process at construction time. Local consumers may surface a confirmation prompt before fully attaching. Always false for new sessions.
So when a session is resumed while another live process is holding it, AlreadyInUse should be true.
Actual behavior
AlreadyInUse is false in that scenario.
Minimal reproduction
Self-contained: two CopilotClient instances in one program (each spawns its own CLI server process, so the second one is genuinely "another process" relative to the first).
using GitHub.Copilot;
#pragma warning disable GHCP001 // SnapshotAsync is experimental
// Client A creates a session, sends one message so it persists to disk,
// then stays alive (its CLI server keeps holding the session).
await using var holder = new CopilotClient();
var held = await holder.CreateSessionAsync(new SessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
});
var sessionId = held.SessionId;
await held.SendAndWaitAsync(new MessageOptions { Prompt = "Reply with exactly: OK" });
// Client B (independent client + CLI server) resumes the SAME session
// using the DEFAULT resume path, then reads the snapshot.
await using var probe = new CopilotClient();
await using var resumed = await probe.ResumeSessionAsync(sessionId, new ResumeSessionConfig
{
OnPermissionRequest = PermissionHandler.ApproveAll,
});
var snapshot = await resumed.Rpc.Metadata.SnapshotAsync();
Console.WriteLine($"AlreadyInUse = {snapshot.AlreadyInUse}"); // prints False; expected True
Observed output
[holder] Created session: f5fdd147-8928-4759-b74c-fd3ffc2b469b
[disk] events.jsonl persisted: True (27817 bytes)
[disk] Lock files present (holder still alive): inuse.20772.lock
[probe] snapshot.AlreadyInUse = False (EXPECTED: True — held by [holder] process)
While probe calls SnapshotAsync(), the session directory
~/.copilot/session-state/f5fdd147-.../ contains inuse.20772.lock, and PID 20772
(the holder's CLI server) is alive — i.e. the session is demonstrably in use by another
process, yet the snapshot reports AlreadyInUse = False.
Supporting evidence
- The session directory contains a per-process lock file named
inuse.<pid>.lockwhose contents are the owning process PID. During the repro this file exists and its PID is a live process, so the "in use by another process" condition is objectively true at snapshot time. - The behavior is identical with
SuppressResumeEvent = trueand with the default resume, so it is not a side effect of suppressing the resume event.
Hypothesized root cause
On the SDK resume path, the runtime does not surface the in-use/lock-detection result onto the metadata snapshot — AlreadyInUse is left at its default (false). The underlying data is available (the lock files are on disk and detection runs), so this looks like the computed value simply isn't propagated to the snapshot for SDK-initiated resumes, whereas a brand-new session correctly reports false.
Test coverage gap / suggested fix
The existing e2e tests assert AlreadyInUse == false only for a freshly-created session, which is correct per the "Always false for new sessions" clause, but none cover a session that is concurrently in use:
dotnet/test/E2E/RpcSessionStateE2ETests.cs→Assert.False(initialSnapshot.AlreadyInUse);go/internal/e2e/rpc_session_state_e2e_test.gonodejs/test/e2e/rpc_session_state.e2e.test.ts→expect(initialSnapshot.alreadyInUse).toBe(false);
Suggested additions:
- Populate
alreadyInUseon the snapshot from the same in-use detection used elsewhere, on the SDK resume path. - Add an e2e test: create + hold a session in one client, resume it from a second client, and assert the second client's snapshot reports
AlreadyInUse == true.
- 主要言語
- TypeScript
- スター
- 10.5k
- フォーク
- 1.5k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 98
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/copilot-sdk のほかの issue
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
github/copilot-sdk#2804 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/copilot-sdk#2798 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
github/copilot-sdk#2793 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/copilot-sdk#2782 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
github/copilot-sdk#2781 ·
メンテナーはふだん 1 日以内に返信
github/copilot-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Doist/todoist-cli#576 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug supabase/cli
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
CopilotKit/aimock#491 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
agilepathway/label-checker#710 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信