Skip to content

feat(agent): sync model when switching agents#124

Open
jeffusion wants to merge 2 commits into
grinev:mainfrom
jeffusion:feat/agent-model-sync
Open

feat(agent): sync model when switching agents#124
jeffusion wants to merge 2 commits into
grinev:mainfrom
jeffusion:feat/agent-model-sync

Conversation

@jeffusion
Copy link
Copy Markdown

Summary

  • Sync the model to the agent's configured model when switching agents via Telegram bot, matching OpenCode TUI behavior
  • If the agent has a model configured in OpenCode config (e.g., via oh-my-opencode), the bot now automatically switches to it
  • If the agent has no model configured, the current model is preserved unchanged
  • Manual model switching via the model picker remains fully independent and unaffected

Changes

  • src/agent/types.ts — Add optional model field to AgentInfo interface
  • src/agent/manager.ts — Map SDK Agent.model to AgentInfo; add getModelForAgent() helper
  • src/bot/handlers/agent.ts — After selecting an agent, sync model + refresh context limit if the agent has a configured model

Test plan

  • All 107 test files pass (895 tests)
  • Build passes with zero errors
  • Lint passes with zero warnings
  • Manual testing: switching agent with configured model syncs the model correctly
  • Manual testing: switching agent without configured model preserves current model
  • Manual testing: manual model switching still works independently

@jeffusion jeffusion force-pushed the feat/agent-model-sync branch from 84e6b54 to 8f89b1d Compare May 18, 2026 12:21
jeffusion added 2 commits May 20, 2026 19:55
When switching agents via the Telegram bot, the model now automatically
syncs to the model configured for that agent in OpenCode config. If the
agent has no model configured, the current model is preserved. Manual
model switching remains independent and unaffected.
Remove /rename as an independent command and unify all session
operations (Select, Rename, Delete) into a session preview panel
accessed via /sessions. This eliminates the fragmented entry points
and ensures a consistent UX for session management.

Key changes:
- Remove /rename command, rename.ts, and RenameManager
- Add preview panel with Select/Rename/Delete/Close actions
- Add session deletion with confirmation dialog and detach cleanup
- Add SSE session.deleted event handling for external deletions
- Add fetchCurrentModelFromSession() to sync model on session switch
- Fix post-attach ordering: model sync before context limit refresh
- Fix agent sync: use clearCurrentAgent() instead of setCurrentAgent("")
- Use sessions.deleted_external i18n key for external deletion notices
@jeffusion jeffusion force-pushed the feat/agent-model-sync branch from 8f89b1d to 58b72b2 Compare May 20, 2026 11:56
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.

1 participant