feat(agent): 运行时从 pi-agent-core 0.99.2 迁到 pi-durable 1.1.0 + pi-ai 1.1.0
- PiAgentRuntime 改用 pi-durable Harness:每个 run 一个 JSONL 存储目录 sessionDir/<runId>/ + root 对话; 系统提示 / 能力工具 / 白名单与预算钩子装在每次运行自己的扩展里;watchEvents 翻译成 AgentRunEvent - 挂起(工具内 close)立即封口,调用保持未完成,重开后 resume 重放;replayGate 用调用级 memo - 旧格式 <runId>.jsonl 打开时抛 LegacySessionError;skills 加载与 <skill> 块格式内置(源自 pi-agent-core,MIT) - tool_call_end 新增可选 durationMs;用量取 pi.usage 合计(整段会话总量) - Azure provider 改名 azure,迁移 0093 改存量;移除 pi-agent-core,锁 pi-durable/pi-ai/chord 1.1.0 - 文档:ADR-003、pi-providers、runbook、agent README、CHANGELOG Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
dd0f6e2c09
commit
003815591c
24 files changed
+756
-363
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { CompactionSettings } from "@earendil-works/pi-agent-core";
|
||||
import { type Api, createModels, createProvider, type Model, type MutableModels } from "@earendil-works/pi-ai";
|
||||
import { anthropicMessagesApi } from "@earendil-works/pi-ai/api/anthropic-messages.lazy";
|
||||
import { openAICompletionsApi } from "@earendil-works/pi-ai/api/openai-completions.lazy";
|
||||
import type { CompactionPolicy } from "@earendil-works/pi-durable";
|
||||
import type { ResolvedAgentSettings } from "../settings.ts";
|
||||
|
||||
/** Pi 侧需要的模型装配结果(仅在 src/pi/* 内部流转) */
|
||||
@@ -62,12 +62,16 @@ export function resolveModelFromSettings(settings: ResolvedAgentSettings): Resol
|
||||
return { models, model };
|
||||
}
|
||||
|
||||
/** 压缩设置:threshold 模式下占用达到 threshold 比例时触发;manual 只允许手动 compact() */
|
||||
export function compactionFromSettings(settings: ResolvedAgentSettings, contextWindow: number): CompactionSettings {
|
||||
/**
|
||||
* 压缩设置:threshold 模式下占用达到 threshold 比例时阻塞压缩;manual 只允许手动 compact()。
|
||||
* backgroundTokens=0:不做 pi-durable 的后台提前压缩,行为与 pi-agent-core 0.99 的阈值压缩一致。
|
||||
*/
|
||||
export function compactionFromSettings(settings: ResolvedAgentSettings, contextWindow: number): CompactionPolicy {
|
||||
const reserveTokens = Math.max(256, Math.round(contextWindow * (1 - settings.compaction.threshold)));
|
||||
return {
|
||||
enabled: settings.compaction.mode === "threshold",
|
||||
reserveTokens,
|
||||
keepRecentTokens: Math.max(256, Math.round(contextWindow * 0.25)),
|
||||
backgroundTokens: 0,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user