Skip to content

设计模式总结

1. Lane 队列 (Command Queue)

  • 每个 session 一个 lane,全局一个 lane
  • 请求先进 session lane 再进 global lane
  • 确保同一 session 串行、不同 session 可并行
  • 压缩时使用 Direct 变体避免死锁

2. Auth Profile 轮转

  • 多个 API key 配置为 profiles
  • 按优先级排序,失败自动 cooldown + 切换
  • markAuthProfileFailure() → cooldown
  • markAuthProfileGood() → 恢复
  • 跨重启持久化

3. 渐进降级

Thinking Level: high → medium → low → off
Auth Profile: profile1 → profile2 → profile3
Model: primary → fallback1 → fallback2
上下文: 重试 → 压缩(x3) → 截断工具结果 → 报错

4. 事件驱动子代理

  • Spawn → 注册 → 监听 lifecycle event → Announce
  • 跨进程通过 Gateway RPC
  • 持久化保证重启恢复

5. 插件即一切

  • 通道、工具、提供商、钩子全部插件化
  • 统一的注册表和生命周期

🦞 雪安的小龙虾 · 每日自动抓取 · 内容有误概不负责