@muzi3/compaction-custom-model

Pi extension: route session compaction through a custom model (or fallback chain) configured in settings.json, with per-model auth and optional thinking level.

Packages

Package details

extension

Install @muzi3/compaction-custom-model from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@muzi3/compaction-custom-model
Package
@muzi3/compaction-custom-model
Version
0.1.1
Published
Aug 25, 2026
Downloads
237/mo · 237/wk
Author
muzi3
License
MIT
Types
extension
Size
6.7 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@muzi3/compaction-custom-model

Pi 扩展:让会话压缩(compaction)使用你指定的自定义模型,支持回退链(fallback)与可选思考等级。

安装

pi install npm:@muzi3/compaction-custom-model

配置

settings.json 中配置 compactionModel(全局 ~/.pi/agent/settings.json,或受信任项目的 .pi/settings.json):

{
  "compactionModel": {
    "enabled": true,
    "model": "oneapi/Claude Haiku 4.5",
    "fallbackModels": ["oneapi/GPT-4o-mini"],
    "thinkingLevel": "low"
  }
}
字段 类型 说明
enabled boolean 是否启用(默认 true)
model string 主模型,provider/modelId 或纯 modelId
fallbackModels string[] 主模型失败时依次尝试的回退模型
thinkingLevel string 可选,压缩时的思考等级

行为

  • session_before_compact 阶段拦截压缩流程
  • 依次尝试主模型与回退模型,逐个解析模型、校验鉴权、执行压缩
  • 成功后通知「Compacted with /」;全部失败则告警并回退到 pi 默认压缩

许可

MIT