Skip to content

SDK permissions: Workspace path is not detected correctly #329955

Open

Description

@joshspicer

Does this issue occur when all extensions are disabled?: Yes/No

ref #329613

Version: 1.133.0-insider
Commit: 36cb0da730a61b80beb0e12f31c8f915ed0afebb
Date: 2026-08-07T10:58:22Z
Electron: 42.8.0
ElectronBuildId: 14845705
Chromium: 148.0.7778.280
Node.js: 24.18.0
V8: 14.8.178.38-electron.0
@github/copilot: 1.0.79-2
@github/copilot-sdk: 1.0.9-preview.3
OS: 36cb0da730a61b80beb0e12f31c8f915ed0afebb

Steps to Reproduce:

  1. Add an Edit() or Read() selector into managed-settings.json with the workspace syntax (/path/to/file )
  2. 🐛 Workspace from VS Code is not calculated correctly, causing incorrect allow/ask/deny behavior

Activity

  1. joshspicer commented on Aug 10, 2026

    @joshspicer
    ContributorAuthor

    AI Correlation

    I correlated this with the recent VS Code-hosted Copilot session logs from the #329613 test pass and traced it into the shared runtime.

    What the logs show

    • The AHP createSession request supplied the correct workspace (file:///Users/josh/git/vscode), and the persisted session cwd was /Users/josh/git/vscode. This is not a VS Code working-directory handoff failure.
    • The tools were classified correctly: apply_patch produced a write permission request with an absolute fileName, and view produced a read request. This is not an alternate-tool bypass.
    • Shell, Domain, and filesystem-root (Read(//tmp/test-file.txt)) rules worked in the same session.
    • Workspace-root path rules did not: Edit(/managed-allow/**) prompted instead of auto-approving, while Edit(/managed-deny/**) prompted and could be approved instead of being denied.

    Root cause

    The runtime's managed path matcher used PathManager.workspace_path() as the /... selector root. For local sessions, that value can be Copilot's internal session-state workspace (for example, ~/.copilot/session-state/<session-id>), not the user's project directory. As a result, /managed-deny/** was expanded under the internal session directory and did not match /Users/josh/git/vscode/managed-deny/...; because managed rules were active, the operation then fell through to the managed default-ask behavior.

    This also explains why an explicit ask selector looked superficially correct: a matched ask and an unmatched operation both prompt under an active managed policy.

    Fix and coverage

    The runtime fix anchors managed /... Read/Edit selectors to the path manager's resolved primary project directory while leaving ./, ~/, //, and internal session-workspace access unchanged.

    Regression coverage now deliberately uses different project and internal session-workspace directories and verifies both Read and Edit allow/deny behavior. The focused tests (2), broader managed-runtime tests (241), Rust formatting/Clippy, and repository format/lint all pass; three independent reviewers found no blocking issues.

    The VS Code-hosted session was on @github/copilot 1.0.79-2, but the root-selection defect was also present on current runtime main, so updating only the bundled CLI version would not resolve it.

  2. joshspicer commented on Aug 10, 2026

    @joshspicer
    ContributorAuthor

    AI trace

    VS Code → SDK → runtime path

    1. The workbench resolves the requested workspace folders and sends them as AHP workingDirectories file URIs.
    2. Agent Host parses those strings back into URI objects. Copilot uses index 0 as the primary/process root.
    3. Copilot sessions are provisional until the first send. For worktree isolation, Agent Host resolves/creates the worktree before materialization and replaces index 0 with that final worktree URI.
    4. CopilotSessionLauncher passes plan.workingDirectory.fsPath to CopilotClient.createSession/resumeSession, forwards secondary roots as additionalDirectories, and sets enableManagedSettings: true.
    5. @github/copilot-sdk forwards those values unchanged in session.create/session.resume.
    6. The runtime stores that filesystem path as the session working directory and initializes the permission path manager's primary directory from it. Infinite-session workspacePath is a separate internal session-state directory.
    7. Before every turn, VS Code synchronizes its approval level through session.rpc.permissions.setAllowAll. Managed deny/ask policy still takes precedence; VS Code also honors managedApprovalRequired and refuses to auto-approve/persist those prompts.
    8. Resume follows the same path using the persisted/resolved working directory (including restored worktrees).

    With the fix, /... managed selectors use the primary directory from step 6, so they line up with the absolute Read/Edit paths emitted by runtime tools. No VS Code-side path conversion change is needed.

    Additional verification

    I added an SDK-shaped runtime regression that creates:

    • a project working directory,
    • a different infinite-session state workspace,
    • managed Edit(/managed-deny/**) and Read(/managed-allow/**) rules,
    • VS Code-style Allow All mode.

    It verifies the edit is still denied and the read is allowed. The expanded managed runtime slice is 242/242 passing. The relevant VS Code tests for resolved worktree → SDK working directory and managed confirmation under global/session Allow All pass; the local VS Code node suite completed with 13,557 passing.

    Remaining gaps

    1. Deployment blocker: the current VS Code checkout/Insiders reproduction bundles @github/copilot 1.0.79-2, which does not contain this runtime fix. The fix must merge, ship in a newer CLI package, and be consumed by VS Code before the manual scenario can pass in-product.
    2. No single cross-repo E2E: runtime now covers the SDK-shaped permission state and VS Code separately covers working-directory forwarding plus managed prompt handling, but no test currently drives AHP createSession all the way through a real managed Read/Edit tool call. That would be the strongest release gate.
    3. VS Code launch invariant is not directly asserted: enableManagedSettings: true is present in CopilotSessionLauncher, but I found no VS Code test that fails if this flag is removed.
    4. Multi-root semantics need a decision: Copilot's hidden multi-root support grants secondary roots as additionalDirectories, while /... managed selectors currently anchor only to the immutable primary root. If /src/** is intended to apply independently to every workspace folder, that behavior and its deny semantics need specification and coverage before multi-root is enabled broadly.
    5. Manual ask cases are ambiguous: an explicit managed ask and an unmatched operation both prompt because active managed policy defaults to ask. Manual verification should always include matching allow and deny cases, not ask alone.
  3. added this to the 1.134.0 milestone on Aug 13, 2026
  4. joshspicer commented on Aug 26, 2026

    @joshspicer
    ContributorAuthor

    Reopening for deployment and in-product verification. A fresh VS Code Agent Host session on August 26 was still running copilot-client-darwin-arm64/1.0.81-0, while the runtime fix in github/copilot-agent-runtime#15396 first shipped in CLI 1.0.81-1.

    The managed policy contained Edit(/managed-deny/**) and the primary workspace was /Users/josh/git/tankgame. An apply_patch call attempted to create /Users/josh/git/tankgame/managed-deny/copilot-permission-probe.txt. Instead of being denied, Agent Host emitted an ordinary permission.requested; after Allow Once, the tool completed with Added 1 file(s).

    Controls in the same session behaved correctly: a native read of /Users/josh/.ssh/config was denied by Read(~/.ssh/**), and a native read of /tmp/test-file.txt was denied by Read(//tmp/test-file.txt). This confirms that managed permissions were loaded and that the failure remained specific to the workspace-root selector path on the pre-fix runtime.

    The pending dependency bump in #332803 moves Agent Host to @github/copilot 1.0.81-12, which should contain #15396. Keeping this issue open until that bump lands and the original Edit(/managed-deny/**) scenario is manually revalidated in VS Code.

  5. joshspicer commented on Aug 26, 2026

    @joshspicer
    ContributorAuthor

    Test-plan provenance: this regression was found while re-running the managed SDK permissions scenarios from TPI #329613. The failing case is the TPI's workspace-root Edit(/managed-deny/**) check with Allow All enabled: it must be denied without an approval option.

    Tracking deployment through #332803 before repeating that TPI case on the updated bundled runtime.

  6. removed their assignment
    on Sep 3, 2026
  7. BatCountry commented on Sep 10, 2026

    @BatCountry

    This was still broken as of 1.136.2, but it's marked as being in a closed milestone and now nobody's assigned. Can we get some eyes on this? joshspicer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions