Files
Agent-System-Backend/internal/runtime/model.go
T
weichen c7736a1917 Integrate the Agent-Squad engine
Details (original message):
Integrate the Agent-Squad engine: squadadapter maps RoleRegistry/RulePlanner/BackendResolver/ProgressSink/HITL onto the unified Run and event model (step subagents, plan updates, deliverable artifacts, confirmation cards); step-wise engine driving loop; model routing respects profile routes with layered resolver + integration tests; context assembly observation flows to run.completed; mock outputs and e2e coverage.
2026-09-29 18:27:49 +00:00

50 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package runtime
import (
core "agent-system-core"
)
// 模型路由解析(4.7 / 4.9 覆盖链):设置层 defaults → system → user → project,
// 画像 ModelRoute 为会话内最高层覆盖(kind 为空回落设置层主模型)。
// 端点与密钥按 kind 独立配置,轻量档空则回落主档。
// ResolvedModel 是一次路由解析的结果。
type ResolvedModel struct {
Kind string // chat | lightweight
Model string
Base string
Key string
}
// ResolveChatModel 解析主对话模型(画像 route > 设置层)。
func ResolveChatModel(prof core.AgentProfile, eff core.EffectiveSettings) ResolvedModel {
m := eff.GetString("models.chat.model", "")
if prof.Model.Chat != "" {
m = prof.Model.Chat
}
return ResolvedModel{Kind: "chat", Model: m,
Base: eff.GetString("models.chat.baseUrl", ""),
Key: eff.GetString("models.chat.apiKey", "")}
}
// ResolveLightweightModel 解析轻量模型:画像 route > 设置层轻量档 > 回落主档。
func ResolveLightweightModel(prof core.AgentProfile, eff core.EffectiveSettings) ResolvedModel {
m := eff.GetString("models.lightweight.model", "")
base := eff.GetString("models.lightweight.baseUrl", "")
key := eff.GetString("models.lightweight.apiKey", "")
if prof.Model.Lightweight != "" {
m = prof.Model.Lightweight
}
if m == "" || base == "" {
// 回落主档(模型与端点分别回落,允许轻量仅覆盖模型名)。
chat := ResolveChatModel(prof, eff)
if m == "" {
m = chat.Model
}
if base == "" {
base, key = chat.Base, chat.Key
}
}
return ResolvedModel{Kind: "lightweight", Model: m, Base: base, Key: key}
}