feat(context): 根据模型动态设置 contextLimit

- AgentConfig 添加 contextWindow 字段
- ProviderRegistry 添加 getModelInfo() 方法查询模型信息
- loadConfig() 从 ProviderRegistry 获取模型的 contextWindow
- Agent 构造函数使用 contextWindow 初始化压缩管理器

效果:
- Anthropic Claude: 168k (200k - 32k 输出预留)
- DeepSeek: 32k (64k - 32k 输出预留)
- 未知模型回退到默认 200k
This commit is contained in:
2025-12-14 23:34:32 +08:00
parent cacd9914fd
commit aefea715b1
4 changed files with 27 additions and 1 deletions
+11
View File
@@ -300,6 +300,17 @@ export class ProviderRegistry {
return [...provider.info.models, ...customModels];
}
/**
* 获取指定模型的详细信息
* @param providerId 提供商 ID
* @param modelId 模型 ID
* @returns 模型信息,未找到时返回 undefined
*/
getModelInfo(providerId: string, modelId: string): ModelInfo | undefined {
const models = this.getModels(providerId);
return models.find((m) => m.id === modelId);
}
/**
* 添加自定义模型
*/