Skip to content

sessionStart and sessionEnd hooks fire per-prompt instead of per-session in interactive mode #991

@torumakabe

Description

@torumakabe

Describe the bug

In interactive mode, sessionStart and sessionEnd hooks are triggered for each prompt/response cycle, not when the interactive session actually starts and ends. According to the documentation, these hooks should execute "when a new agent session begins" and "when the agent session completes or is terminated."

Affected version

0.0.383

Steps to reproduce the behavior

  1. Create hooks.json with sessionStart and sessionEnd hooks that log to a file
  2. Start Copilot CLI in interactive mode: copilot
  3. Submit a prompt (e.g., "Display the current time")
  4. Check the log file - observe sessionStart and sessionEnd entries
  5. Submit another prompt within the same interactive session
  6. Check the log file again - observe additional sessionStart and sessionEnd entries

Expected behavior

  • sessionStart should fire once when the interactive session begins (copilot command executed)
  • sessionEnd should fire once when the interactive session ends (user exits with /exit or Ctrl+D)
  • For per-prompt logging, userPromptSubmitted hook should be used instead

Additional context

  • Operating system: Linux
  • CPU architecture: x86_64
  • Shell: zsh
{
    "version": 1,
    "hooks": {
        "sessionStart": [{"type": "command", "bash": ".github/hooks/scripts/session-start.sh"}],
        "sessionEnd": [{"type": "command", "bash": ".github/hooks/scripts/session-end.sh"}]
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions