Skip to content

feat(plugin): add session.start hook for session initialization - #15224

Closed
coalminer1776 wants to merge 3 commits into
anomalyco:devfrom
coalminer1776:dev
Closed

coalminer1776 wants to merge 3 commits into
anomalyco:devfrom
coalminer1776:dev

Conversation

@coalminer1776

@coalminer1776 coalminer1776 commented Feb 26, 2026 •

Copy link
Copy Markdown

Issue for this PR

Feature request for session.start hook - addresses similar functionality to Claude Code's SessionStart hook for session initialization.

Type of change

  • New feature

What does this PR do?

Adds a new plugin hook session.start that fires when the first message is sent in a session. This allows plugins to inject custom context into the system prompt at session start.

Changes made:

  1. Added session.start hook type definition in packages/plugin/src/index.ts
  2. Added trigger logic in packages/opencode/src/session/prompt.ts that:
    • Detects first message in a session
    • Triggers prompt is built
    • Injects the hook before system plugin-returned context into the system prompt

Why it works:
The implementation follows the same pattern as existing hooks like experimental.chat.system.transform and other session hooks in the codebase. Plugins can now register a session.start hook that receives session info and returns context strings which are prepended to the system prompt.

How did you verify your code works?

  • TypeScript compilation passes (bun run typecheck)
  • Build succeeds (bun run build)
  • Code follows existing hook patterns in the codebase
  • Manual testing required to fully verify hook fires correctly at runtime

Screenshots / recordings

N/A - no UI changes

Checklist

  • I have tested my changes locally (typecheck, build)
  • I have not included unrelated changes in this PR

coalminer1776 added 3 commits February 26, 2026 09:35
- Add session.start hook type to plugin system
- Trigger hook on first message in session
- Allows plugins to inject context into system prompt
- Plugin demonstrates session.start hook functionality
- Logs when hook fires
- Injects test context into system prompt
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Feb 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@MattPark

Copy link
Copy Markdown

Yeah we need this to add a custom agent set for the team!

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

@thdxr thdxr closed this Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants