Feature Request: Add session_start hook for session lifecycle #8508

Open
opened 2026-02-16 18:10:09 -05:00 by yindo · 1 comment
Owner

Originally created by @BruceWae on GitHub (Feb 4, 2026).

Originally assigned to: @thdxr on GitHub.

Summary

Request to add a session_start hook to complement the existing session_completed hook, enabling actions to be triggered when a new session begins.

Use Case

I'm using a Continuous Learning MCP Server that stores user preferences and learned patterns across sessions. Currently:

  • session_completed hook exists - can save state when session ends
  • session_start hook missing - cannot auto-load state when session begins

This means the MCP can save memories, but there's no way to automatically read them at the start of a new session. Users must manually trigger the read operation.

Proposed Solution

Add session_start to the experimental hooks:

// Current (from opencode-sdk-go/config.go)
type ConfigExperimentalHook struct {
    FileEdited       map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
    SessionCompleted []ConfigExperimentalHookSessionCompleted      `json:"session_completed"`
}

// Proposed
type ConfigExperimentalHook struct {
    FileEdited       map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
    SessionCompleted []ConfigExperimentalHookSessionCompleted      `json:"session_completed"`
    SessionStart     []ConfigExperimentalHookSessionStart          `json:"session_start"` // NEW
}

Example Configuration

{
  "experimental": {
    "hooks": {
      "session_start": [
        {
          "command": ["node", "scripts/load-context.js"]
        }
      ]
    }
  }
}

Reference

Claude Code supports SessionStart hooks which enables this workflow. See: everything-claude-code hooks.json

Impact

This would enable:

  1. Auto-loading user preferences/context at session start
  2. Persistent memory across sessions
  3. Better integration with learning/memory MCP servers
  4. Parity with Claude Code's hook capabilities

Thank you for considering this feature!

Originally created by @BruceWae on GitHub (Feb 4, 2026). Originally assigned to: @thdxr on GitHub. ## Summary Request to add a `session_start` hook to complement the existing `session_completed` hook, enabling actions to be triggered when a new session begins. ## Use Case I'm using a **Continuous Learning MCP Server** that stores user preferences and learned patterns across sessions. Currently: - ✅ `session_completed` hook exists - can save state when session ends - ❌ `session_start` hook missing - cannot auto-load state when session begins This means the MCP can save memories, but there's no way to automatically read them at the start of a new session. Users must manually trigger the read operation. ## Proposed Solution Add `session_start` to the experimental hooks: ```go // Current (from opencode-sdk-go/config.go) type ConfigExperimentalHook struct { FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"` SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"` } // Proposed type ConfigExperimentalHook struct { FileEdited map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"` SessionCompleted []ConfigExperimentalHookSessionCompleted `json:"session_completed"` SessionStart []ConfigExperimentalHookSessionStart `json:"session_start"` // NEW } ``` ## Example Configuration ```json { "experimental": { "hooks": { "session_start": [ { "command": ["node", "scripts/load-context.js"] } ] } } } ``` ## Reference Claude Code supports `SessionStart` hooks which enables this workflow. See: [everything-claude-code hooks.json](https://github.com/affaan-m/everything-claude-code/blob/main/hooks/hooks.json) ## Impact This would enable: 1. Auto-loading user preferences/context at session start 2. Persistent memory across sessions 3. Better integration with learning/memory MCP servers 4. Parity with Claude Code's hook capabilities Thank you for considering this feature!
Author
Owner

@github-actions[bot] commented on GitHub (Feb 4, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5409: [FEATURE]: SessionStart hook for session lifecycle events

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 4, 2026): This issue might be a duplicate of existing issues. Please check: - #5409: [FEATURE]: SessionStart hook for session lifecycle events Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8508