diff --git a/mateclaw-server/src/main/java/vip/mate/agent/AgentGraphBuilder.java b/mateclaw-server/src/main/java/vip/mate/agent/AgentGraphBuilder.java index 2bcddb83..eefb47b1 100644 --- a/mateclaw-server/src/main/java/vip/mate/agent/AgentGraphBuilder.java +++ b/mateclaw-server/src/main/java/vip/mate/agent/AgentGraphBuilder.java @@ -155,9 +155,13 @@ public class AgentGraphBuilder { // the agent's bound-skill requires-model. Falls back to the // global default when no preferred provider satisfies, so the // existing "no default model" error path stays intact. + // RFC-03 Lane G1 — honor per-Agent model override when set. + // resolveModel() looks up entity.modelName in enabled-only models; + // null / blank / unmatched silently fall back to getDefaultModel(), + // preserving the legacy behavior for Agents without an override. ModelConfigEntity globalDefault; try { - globalDefault = modelConfigService.getDefaultModel(); + globalDefault = modelConfigService.resolveModel(entity.getModelName()); } catch (Exception e) { throw new MateClawException("err.agent.no_default_model", "无法构建 Agent:请先在「设置 → 模型」中配置并启用默认模型"); } diff --git a/mateclaw-server/src/main/java/vip/mate/agent/model/AgentEntity.java b/mateclaw-server/src/main/java/vip/mate/agent/model/AgentEntity.java index 87b7bf9c..cda34962 100644 --- a/mateclaw-server/src/main/java/vip/mate/agent/model/AgentEntity.java +++ b/mateclaw-server/src/main/java/vip/mate/agent/model/AgentEntity.java @@ -31,10 +31,22 @@ public class AgentEntity { private String systemPrompt; /** - * 保留但不再生效:运行时统一使用全局默认模型(ModelConfigService.getDefaultModel())。 - * 该字段为历史残留,仅保留以避免数据库迁移。 + * Per-Agent model override. + * + *

When non-blank, the runtime resolves this value via + * {@code ModelConfigService.resolveModel(...)} — a case-sensitive, + * enabled-only lookup against {@code mate_model_config.model_name}. + * On match, the resolved entity is used as the primary model in + * place of {@code getDefaultModel()}. + * + *

Null / blank → fall back to the global default (preserves the + * original behavior). Stale rows whose named model has been removed + * or disabled also fall back, since {@code resolveModel} returns the + * default when no enabled match is found. + * + *

RFC-03 Lane G1 — re-enables this field after it was silently + * deprecated in earlier work; the database column is unchanged. */ - @Deprecated private String modelName; /** 最大迭代次数 */ diff --git a/mateclaw-server/src/main/resources/messages.properties b/mateclaw-server/src/main/resources/messages.properties index a9c51900..d05a471e 100644 --- a/mateclaw-server/src/main/resources/messages.properties +++ b/mateclaw-server/src/main/resources/messages.properties @@ -233,6 +233,7 @@ err.llm.pkce_failed=PKCE \u751f\u6210\u5931\u8d25 err.llm.chatgpt_stream_failed=ChatGPT \u6d41\u5f0f\u8c03\u7528\u5931\u8d25 err.llm.chatgpt_error=ChatGPT \u8fd4\u56de\u9519\u8bef err.llm.chatgpt_account_missing=chatgpt-account-id \u7f3a\u5931 +err.llm.model_not_supported=\u6a21\u578b ID \u4e0d\u652f\u6301\u5728 DashScope \u539f\u751f\u534f\u8bae\u4e2d\u4f7f\u7528\u3002\u70b9\u7248\u672c\u683c\u5f0f\u7684\u7cfb\u5217\uff08\u4f8b\u5982 qwen3.5-*\u3001qwen3.6-*\uff09\u53ea\u80fd\u901a\u8fc7\u517c\u5bb9\u6a21\u5f0f\u4f7f\u7528\u3002\u8bf7\u4f7f\u7528\u5141\u8bb8\u7684 ID\uff0c\u5982 qwen-max / qwen-plus / qwen3-max\u3002 # datasource err.datasource.not_found=\u6570\u636e\u6e90\u4e0d\u5b58\u5728 err.datasource.sql_empty=SQL \u4e0d\u80fd\u4e3a\u7a7a diff --git a/mateclaw-ui/src/i18n/locales/en-US.ts b/mateclaw-ui/src/i18n/locales/en-US.ts index 925e8742..3e0a9bf5 100644 --- a/mateclaw-ui/src/i18n/locales/en-US.ts +++ b/mateclaw-ui/src/i18n/locales/en-US.ts @@ -773,6 +773,9 @@ export default { systemPrompt: 'System Prompt', maxIterations: 'Max Iterations', defaultThinkingLevel: 'Default Thinking Level', + modelName: 'Model', + modelGlobalDefault: 'Use global default', + modelHint: 'Override the global default model for this Agent. Leave blank to follow Settings → Models.', tags: 'Tags', enabled: 'Enabled', }, diff --git a/mateclaw-ui/src/i18n/locales/zh-CN.ts b/mateclaw-ui/src/i18n/locales/zh-CN.ts index 64a77213..0ed52cc8 100644 --- a/mateclaw-ui/src/i18n/locales/zh-CN.ts +++ b/mateclaw-ui/src/i18n/locales/zh-CN.ts @@ -775,6 +775,9 @@ export default { systemPrompt: '系统提示词', maxIterations: '最大迭代次数', defaultThinkingLevel: '默认思考深度', + modelName: '模型', + modelGlobalDefault: '使用全局默认模型', + modelHint: '为此 Agent 单独指定模型,留空则跟随「设置 → 模型」中的全局默认。', tags: '标签', enabled: '启用', }, diff --git a/mateclaw-ui/src/views/Agents.vue b/mateclaw-ui/src/views/Agents.vue index 44cca205..d8b5e5b8 100644 --- a/mateclaw-ui/src/views/Agents.vue +++ b/mateclaw-ui/src/views/Agents.vue @@ -204,6 +204,18 @@ + +

+ + +

{{ t('agents.fields.modelHint') }}

+