Add per-session model overrides - #5992
Conversation
|
Hi @mango8853, thank you for your first Pull Request! 🎉 📋 About PR TemplateTo help maintainers review your PR faster, please make sure to include:
Complete PR information helps speed up the review process. You can edit the PR description to add these details. 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
|
when I create an agent on qwenpaw, using different apis and different models, expected to give different session a different model, especially fast model for group member, big model for single chat. But I found that qwenpaw setting one model for one agent, so I make this modify and esaily swap model in /model commands and webui. I've been using this agent from Copaw to Qwenpaw, and I'm glad to see how much it's improved. So I decided to make a small contribution. |
…overrides # Conflicts: # src/qwenpaw/runtime/builder.py
RerankerGuo
left a comment
There was a problem hiding this comment.
Independent review at exact head f32cba8e62a00a0b9996cdaf43debab9580b4f5e (macOS arm64, Python 3.11.15, Node 22). The merge base is current main bacac7410cf2ac122dd892152beff8b03f38729f, so no semantic trial resolution is needed.
The core persisted-resolution tests pass:
test_agent_model.py
test_provider_context_window.py
test_base_core.py
89 passed, 1 skipped
provider.test.ts + ModelSelector.test.tsx
29 passed
git diff --check
passed
remote Real behavior proof
passed
I found one user-visible scope regression that the current tests do not cover. When per-session models are enabled on /chat/new, resolveRuntimeSessionIdForModel() deliberately returns undefined because the new chat has no resolved runtime session ID. ModelSelector still remains interactive, and its buildModelSlotRequest() then silently falls back to scope: "agent".
An external component regression that enables the feature, renders the selector without a resolved sessionId, and selects GPT-3.5 fails with:
expected setActiveLlm not to be called with scope="agent"
received:
{
"provider_id": "openai",
"model": "gpt-3.5-turbo",
"scope": "agent",
"agent_id": "default"
}
This means a user who enabled per-session models and selects a model before sending the first message changes the model for the entire Agent, contrary to the opt-in UI contract. Please either disable/defer model selection until the new chat has a runtime session ID, or carry a pending session identity that is also used by the first backend turn. A regression should cover session_model_overrides_enabled=true with no resolved session ID and prove that no Agent-wide write occurs.
The exact changed-file pre-commit run also has merge-gate failures:
mypy:
src/qwenpaw/app/routers/providers.py:1011
Argument 1 to load_agent_config has incompatible type "str | None"; expected "str"
black:
reformats src/qwenpaw/runtime/commands/control/model_handler.py
src/qwenpaw/app/routers/providers.py
pylint:
model_factory.py:1393 R0915 too-many-statements (54/50)
providers.py:1046 R0915 too-many-statements (51/50)
All other applicable changed-file hooks passed. actionlint was skipped because this PR changes no workflow files.
The per-session resolution direction is sound, but the new-chat scope boundary and pinned repository hooks need to be clean before merge.
|
thanks for review! I did fixed it. |
|
Hi @mango8853, 感谢你的贡献 建议参考项目中 session_project_dir 的设计模式,对方案进行简化:
|
|
hi, @zhijianma ,非常感谢您的回复,确实现在的改动太重了。在考虑了您的建议后,我觉得还是缺少一个直观判别每个会话在用什么模型的指示,如果在控制-会话里面的列表中,channel后面增加一列model来显示每个会话使用的模型,您觉得这个改动能接受吗? |
我感觉是没有必要的,我更倾向于在ModelSelector中修改 和 回显, 而不再是 agent 维度的修改。当然新建对话的初始模型暂时复用agent模型。 |
…overrides # Conflicts: # src/qwenpaw/config/config.py
好的,已经按要求修改了 |
|
有几个问题:
|
…overrides # Conflicts: # console/src/pages/Chat/index.tsx # tests/unit/agents/tools/test_view_media.py
了解了,修复了并检查了其他地方 |


Description
This PR adds opt-in per-session model overrides so a single Agent can use different LLMs for different conversations without changing QwenPaw's existing default behavior.
Per-session models are disabled by default. When disabled, the Chat model selector and
/modelcommand continue to switch the model for the whole Agent. Users can enable per-session behavior from Settings > Models; saved session overrides are preserved but ignored while the feature is disabled.The PR also adds a modal for reviewing and managing effective models across Agents and sessions, and updates the Chat header to display the model that is effective for the current session.
Related Issue: Relates to per-session model configuration support.
Security Considerations: No new secrets or authentication paths are introduced. The global opt-in flag is stored in the existing root config, while provider/model IDs for overrides remain in Agent profile configuration.
Behavior
/modelread, switch, list, and reset at Agent scope./modelread and write the current session override.409while the feature is disabled, preventing stale clients from bypassing the setting.Evidence
Real behavior was verified on a deployed QwenPaw instance before updating the PR:
enabled: falseby default.Example effective-model query using placeholders:
Type of Change
Component(s) Affected
Checklist
pre-commit run --all-fileslocally and it passespytestor as relevant) and they passFor Channel Changes (DingTalk, Lark, QQ, Console, etc.)
./scripts/check-channels.sh(or./scripts/check-channels.sh --changed) and it passestests/contract/channels/test_<channel>_contract.py(REQUIRED)create_instance()with proper channel initializationtests/contract/channels/__init__.py)tests/unit/channels/test_<channel>.pyfor complex internal logicTesting
/modelchange the Agent model./modelreport the current session's effective model.Local Verification Evidence
Additional Notes
The
AI Review Approvalcheck uses theai-review-approvedGitHub environment and must be approved by a maintainer before the AI review job can run.