Skip to content

Extension lifecycle hooks receive empty workingDirectory since CLI ~1.0.51 #3508

@brycecutt-msft

Description

@brycecutt-msft

Describe the bug

Starting around CLI version 1.0.51, extension lifecycle hooks (onSessionStart, onPreToolUse, onUserPromptSubmitted) receive an empty string "" for workingDirectory in the hook input.

Previously (CLI 1.0.49 and earlier), the hook input contained the actual working directory path where the CLI session was started.

Affected version

1.0.51, 1.0.52, 1.0.53, 1.0.54

Steps to reproduce the behavior

  1. Create an extension that uses the working directory in any lifecycle hook:
export function joinSession(session) {
  return {
    hooks: {
      onSessionStart: (input) => {
        // input.workingDirectory is "" instead of the actual path
        if (!input.workingDirectory) {
          throw new Error("workingDirectory is empty");
        }
      }
    }
  };
}
  1. Start a Copilot CLI session (v1.0.51+) in any directory
  2. input.workingDirectory is "" (empty string)

Expected behavior

input.workingDirectory should contain the actual working directory path (e.g., C:\Users\me\my-project or /home/me/my-project), matching the BaseHookInput type definition in the SDK.

Additional context

  • Operating system: Windows 11, x86_64
  • Terminal emulator: Windows Terminal
  • Shell: PowerShell

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions