Skip to content

No way to run user code at session boundaries (start/end/checkpoint) #2548

@adstuart

Description

@adstuart

Describe the feature or problem you'd like to solve

Custom instructions can ask the model to perform tasks at session start (e.g. "sync session history on startup"), but this is unreliable. The model may skip instructions due to context window limits, prioritisation, or simply not following them consistently — especially in long sessions.

On the exit side, there are no hooks at all. /exit, /clear, /new, Ctrl+C, and Ctrl+D all terminate immediately with no opportunity to run cleanup or sync logic.

This means there's no reliable way to:

  • Run a script when a session starts or ends
  • Sync or archive session data to an external system
  • Trigger any user-defined logic at session boundaries

The key issue is that custom instructions are model-dependent — they're suggestions, not guarantees. For workflows that need to run every time, there should be a code-based mechanism that the CLI runtime executes regardless of model behaviour.

Example workflows this would enable

  • Archiving session summaries after each session
  • Syncing session data to external storage or a team log
  • Running setup/teardown scripts that must execute reliably

Metadata

Metadata

Assignees

No one assigned

    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