Skip to content

fix: preserve model for exit notifications#50

Merged
shekohex merged 1 commit into
shekohex:mainfrom
TTTPOB:fix/preserve-notification-model
Jul 21, 2026
Merged

fix: preserve model for exit notifications#50
shekohex merged 1 commit into
shekohex:mainfrom
TTTPOB:fix/preserve-notification-model

Conversation

@TTTPOB

@TTTPOB TTTPOB commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • read the parent session's current model before sending a PTY exit notification
  • pass its provider, model ID, and variant to promptAsync
  • retain the existing notification behavior when an older OpenCode server does not expose Session.model

Problem

sendExitNotification() currently passes the originating agent but omits the model and variant. OpenCode resolves a prompt without an explicit model as:

input.model ?? agent.model ?? currentModel(sessionID)

If the agent's configured default differs from the model selected for the current session, the generated <pty_exited> user turn switches the session to that default. All subsequent assistant turns then use the wrong model.

This uses only the standard OpenCode session.get and promptAsync APIs. It does not depend on another plugin. The local compatibility cast is needed because the package's pinned SDK type predates the runtime Session.model field.

Verification

  • bun test test/notification-manager.test.ts
  • bun typecheck
  • bun lint
  • bun format
  • fork CI: unit tests, E2E tests, typecheck, lint, format, and Nix checks
  • live OpenCode 1.18.3 run: a gpt-5.6-terra/high session received a <pty_exited> notification and retained gpt-5.6-terra/high on the notification user message, subsequent assistant messages, and session summary

@TTTPOB

TTTPOB commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

need to mention the reason why i need this is:
i wrote a plugin that enable the main agent choose model and variant dynamiclly when creating subagent, so it may be different from default model in agent config.

@shekohex

Copy link
Copy Markdown
Owner

LGTM, thanks!

@shekohex
shekohex merged commit cc12a2b into shekohex:main Jul 21, 2026
7 checks passed
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.

2 participants