/spawn command template instructs the agent to reuse an existing session, contradicting its own singular-spawn contract - and no approval gate on the resulting cross-session write
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Shell
- Star
- 11.2k
- Fork
- 1.9k
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 6
Mô tả
Describe the bug
The /spawn command's expanded prompt template contradicts itself, and the contradiction resolves in the destructive direction: it can silently turn "create a child session" into "inject context into an unrelated running session."
The template opens with a singular-spawn contract:
Spawn exactly ONE child session — this is the singular gesture, not a fan-out.
Step 3 then instructs create_session with a complete standalone kickoff.prompt. But step 2 says:
Check
list_sessions_and_chatsso you reuse an existing session instead of creating a duplicate for work already in flight.
Step 2 contradicts both. When it wins, the result is a send_session_message into a different session — a fundamentally different action from the one /spawn promises, with a different blast radius, executed with no confirmation.
What happened
I invoked /spawn explicitly with this appended instruction:
a session to focus on addressing this narrowness. What guidance files need to be updated to ensure next times it happens correctly? The session will be interactive and not change anything until the user is happy.
Nothing there names or implies an existing session. The agent replied:
Reused the existing "Interactive ingestion rules" session in the 2ndBrain repository rather than creating a duplicate. It will inspect the relevant guidance files and propose precise updates—without modifying anything until you approve them.
That is step 2's language, near-verbatim. The agent followed the spec. The target it selected was a sibling session created seven minutes earlier on an adjacent topic — plausible under a loose reading of "work already in flight," and actively wrong: that session had its own task, and the injection redirected it.
Expected behavior
/spawn creates a new session. If the agent believes an existing session is a better target, it surfaces the candidate and asks — it does not substitute silently.
What's defective in step 2
- It contradicts the command's own stated contract. The template says "singular gesture" and "call
create_session", then instructs reuse. - "Work already in flight" is unbounded. No similarity threshold, no recency bound, no repo/task scoping. Topical adjacency is enough to trigger it.
- Reuse is silent. No confirmation before the write; the user finds out after it has landed.
- The two branches have asymmetric blast radii. Spawning a superfluous session is additive and trivially discarded. Reuse mutates a running session's conversation — it corrupts work in progress, and the damage isn't visible until that session produces a wrong result. Deduplication logic should never silently pick the destructive branch.
Point 4 is the core of it: this is framed as a deduplication nicety, but the "duplicate" it avoids is cheap while the mutation it performs is not.
Suggested fix
Either:
- Remove step 2.
/spawnmeans spawn. Deduplication across existing work belongs in/orchestrateor/fleet, where multi-session coordination is the explicit contract; or - Make detection advisory. Keep the
list_sessions_and_chatscheck, but require explicit user confirmation — showing target session name/ID and a preview of the message — before messaging instead of creating.
Related: no permission surface for cross-session writes
This is what let a template ambiguity become a silent mutation, and it stands independently of the /spawn fix.
permissions-config.json supports write, shell, and mcp approvals, but has no concept of "this agent may inject context into another session." Cross-session messaging appears to be the only side-effecting capability with no permission surface at all. Worth adding a permission kind for it, and/or a policy such as alwaysAskBeforeCrossSessionMessage, defaulting to on.
Workaround
I added rules to ~/.copilot/copilot-instructions.md requiring ask_user approval before any send_session_message, and forbidding substitution of an existing session for a spawn request. This helps, but it's instruction-level guidance competing with the command template's own step 2 — it degrades under context pressure and doesn't protect users who don't know to write it.
Related issues
- #2436 (Cross-Session Context Querying) proposes expanding cross-session reach, including a "session-as-agent" model — roughly the capability that misfired here. It doesn't discuss consent or approval. The more this capability grows, the more it needs a boundary; the two issues are complementary, not competing.
- #4153 (closed) —
create_sessiondropped kickoff prompts. A different spawn-path bug, but adjacent.
Versions
Copilot CLI / App version: 1.0.79-9
OS: Windows
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Kiểm tra prompt mở rộng của /spawn, đặc biệt là bước 2, cùng với permissions-config.json và các điểm vào create_session và send_session_message. Xác định hiện tại việc tạo session và ghi giữa các session được xử lý như thế nào; được coi là hoàn tất khi /spawn tạo một session con hoặc yêu cầu xác nhận trước khi tái sử dụng một session, với việc nhắn tin giữa các session được bao phủ bởi một policy phê duyệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- shell
- Lĩnh vực
- authorization, cli, security
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100