refactor: Agent 配置硬编码化、压缩系统不可变重构、前端组件化与安全硬化
- AgentConfig: 移除 10+ 个环境变量读取,仅保留 TOKEN_SOFT/HARD_LIMIT 两个
可调参数,context_char_limit 替换为统一的 token_soft_limit 阈值
- compact: find_safe_cut_point 重写为 HashSet O(n) 算法,
micro_compact 改为不可变风格,compress_context 签名升级为
token_soft_limit + max_messages 双参数,新增 COMPACTION_OUTPUT_RESERVE
- modes: ModeConfig.max_steps/tool_timeout_secs 去 Optional 化,
Deep Research 步数 16→100,Literature Reader 步数 6→25
- dashboard: 提取 AgentMarkdown/ThoughtCard/ToolCallCard/AnswerCard/
SubAgentContainer 等共享组件,ResearchAgentPanel 大幅瘦身,
交互卡片重构为 console-panel 紧凑风格
- security: 移除 HERMES_YOLO_MODE、AGENT_BLOCK_NETWORK 开关、
AGENT_CHECKPOINT_ENABLED 开关,关键安全机制强制启用
This commit is contained in:
@@ -171,12 +171,19 @@ let est_tokens: usize = messages
|
||||
.iter()
|
||||
.map(|m| m.content.as_ref().map_or(0, |c| c.len()) + 4)
|
||||
.sum();
|
||||
if est_tokens > self.config.context_char_limit * 3 / 2 {
|
||||
compact::compress_context(&mut messages, llm, config.context_char_limit, "subagent").await;
|
||||
if est_tokens > self.config.token_soft_limit * 3 / 2 {
|
||||
compact::compress_context(
|
||||
&mut messages,
|
||||
llm,
|
||||
config.token_soft_limit,
|
||||
config.max_messages,
|
||||
"subagent",
|
||||
)
|
||||
.await;
|
||||
}
|
||||
```
|
||||
|
||||
- 触发阈值:`context_char_limit * 1.5`(默认 ~24000 字符)
|
||||
- 触发阈值:`token_soft_limit * 1.5`(默认 ~48000 tokens)
|
||||
- 压缩方式:调用 `compact::compress_context`(LLM 摘要压缩)
|
||||
- 标识来源:`"subagent"`,区别于 `"lead"` / `"teammate"` / `"background"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user