Skip to content

Feature Request: Add session_start hook for session lifecycle #12110

@BruceWae

Description

@BruceWae

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!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions