[FEATURE]: Pass sessionID and callID to shell.env hook input #9363

Open
opened 2026-02-16 18:12:16 -05:00 by yindo · 2 comments
Owner

Originally created by @tesdal on GitHub (Feb 14, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The shell.env hook currently receives only { cwd: string } as input. Unlike tool.execute.before and tool.execute.after, which both receive sessionID and callID, shell.env has no way to identify which tool invocation triggered it.

Proposed change: Add optional sessionID and callID fields to the shell.env input:

"shell.env"?: (
  input: { cwd: string; sessionID?: string; callID?: string },
  output: { env: Record<string, string> },
) => Promise<void>

The fields are optional because the PTY call site (pty/index.ts) has no session context. The two tool-related call sites (bash.ts, prompt.ts) already have both values in scope.

This is the same pattern used when sessionID was added to chat.system.transform (#7718) and args was added to tool.execute.after (56ad2db02). Additive, non-breaking, backward-compatible.

Originally created by @tesdal on GitHub (Feb 14, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request The `shell.env` hook currently receives only `{ cwd: string }` as input. Unlike `tool.execute.before` and `tool.execute.after`, which both receive `sessionID` and `callID`, `shell.env` has no way to identify which tool invocation triggered it. **Proposed change:** Add optional `sessionID` and `callID` fields to the `shell.env` input: ```ts "shell.env"?: ( input: { cwd: string; sessionID?: string; callID?: string }, output: { env: Record<string, string> }, ) => Promise<void> ``` The fields are optional because the PTY call site (`pty/index.ts`) has no session context. The two tool-related call sites (`bash.ts`, `prompt.ts`) already have both values in scope. This is the same pattern used when `sessionID` was added to `chat.system.transform` (#7718) and `args` was added to `tool.execute.after` (56ad2db02). Additive, non-breaking, backward-compatible.
yindo added the discussion label 2026-02-16 18:12:16 -05:00
Author
Owner

@smola commented on GitHub (Feb 15, 2026):

Not exactly a duplicate, but see this related issue: https://github.com/anomalyco/opencode/issues/9292

@smola commented on GitHub (Feb 15, 2026): Not exactly a duplicate, but see this related issue: https://github.com/anomalyco/opencode/issues/9292
Author
Owner

@tesdal commented on GitHub (Feb 15, 2026):

Thanks @smola – I think this is more symmetric and consistent with how it's done in other events/hooks, and with this change you can easily make your own plugin to get the functionality in #9292 if it takes a while to decide on whether #9292 should land and you want to experiment a bit without having to work opencode.

@tesdal commented on GitHub (Feb 15, 2026): Thanks @smola – I think this is more symmetric and consistent with how it's done in other events/hooks, and with this change you can easily make your own plugin to get the functionality in #9292 if it takes a while to decide on whether #9292 should land and you want to experiment a bit without having to work opencode.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9363