Skip to content

feat(agent): enhance agent model management and command handling#1093

Closed
linsheng9731 wants to merge 3 commits intosipeed:mainfrom
linsheng9731:feat/tele_add_switch
Closed

feat(agent): enhance agent model management and command handling#1093
linsheng9731 wants to merge 3 commits intosipeed:mainfrom
linsheng9731:feat/tele_add_switch

Conversation

@linsheng9731
Copy link
Copy Markdown

📝 Description

This PR adds runtime model switching via command in chat channels and makes the switch effective immediately without restarting the gateway.

Main changes:

  • Add /switch model <name> command support in Telegram and Discord.
  • Route switch requests through the agent command pipeline for consistent behavior.
  • Implement ModelSwitchManager runtime switch flow:
    • validate target model
    • update default model
    • recreate provider
    • hot-swap agent registry instances
    • rollback on failure
  • Improve default-agent selection determinism in AgentRegistry.
  • Add unit tests for model switching and Telegram switch allowlist behavior.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

N/A

📚 Technical Context (Skip for Docs)

  • Reference URL: N/A
  • Reasoning:
    Previously, channel-level switch command handling updated config/model fields but did not fully guarantee runtime consistency (provider/candidate refresh and unified authorization path).
    This PR centralizes runtime switching in ModelSwitchManager and updates registry state atomically, while adding tests to reduce regression risk.

🧪 Test Environment

  • Hardware: Mac (development machine)
  • OS: macOS (Darwin 25.1.0)
  • Model/Provider: Configured provider from model_list (runtime switch tested with configured aliases)
  • Channels: Telegram, Discord

📸 Evidence (Optional)

Click to view Logs/Screenshots
  • Build succeeded: make build
  • Targeted tests passed:
    • go test ./pkg/agent ./pkg/channels/telegram
    • go test ./pkg/agent ./pkg/channels/discord ./pkg/channels/telegram
  • Runtime check:
    • Gateway starts successfully with new binary
    • GET /health returns {"status":"ok",...}

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

- Added model switching functionality for agents, allowing dynamic model changes at runtime.
- Introduced a new command handler for Telegram and Discord channels to facilitate model switching.
- Updated agent registry to manage default agent selection and model resolution.
- Enhanced configuration management to support default model settings.
- Improved candidate resolution logic for agent instances.
- Added tests for default agent retrieval and fallback behavior.
…ttings

- Introduced a config field in the DiscordChannel struct to manage proxy settings.
- Updated the downloadAttachment method to utilize the new configuration for proxy URLs.
@linsheng9731
Copy link
Copy Markdown
Author

hi @lxowalle , @yinwm could you please review this PR?

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

Made-with: Cursor

# Conflicts:
#	go.mod
#	pkg/agent/instance.go
#	pkg/config/config.go
@sipeed-bot
Copy link
Copy Markdown

sipeed-bot Bot commented Mar 25, 2026

@linsheng9731 Hi! This PR has had no activity for over 2 weeks, so I'm closing it for now to keep things organized. Feel free to reopen anytime if you'd like to continue.

@sipeed-bot sipeed-bot Bot closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants